2012-06-29 01:34:05 +00:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
|
2014-12-23 18:26:10 +00:00
|
|
|
if sys.version_info[:2] < (2, 6):
|
|
|
|
sys.exit('virtualenv requires Python 2.6 or higher.')
|
|
|
|
|
2010-06-01 20:45:04 +00:00
|
|
|
try:
|
|
|
|
from setuptools import setup
|
2014-12-23 18:26:10 +00:00
|
|
|
from setuptools.command.test import test as TestCommand
|
|
|
|
|
|
|
|
class PyTest(TestCommand):
|
|
|
|
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
TestCommand.initialize_options(self)
|
|
|
|
self.pytest_args = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
TestCommand.finalize_options(self)
|
|
|
|
self.test_args = []
|
|
|
|
self.test_suite = True
|
|
|
|
|
|
|
|
def run_tests(self):
|
|
|
|
# import here, because outside the eggs aren't loaded
|
|
|
|
import pytest
|
|
|
|
errno = pytest.main(self.pytest_args)
|
|
|
|
sys.exit(errno)
|
|
|
|
|
2012-06-29 01:34:05 +00:00
|
|
|
setup_params = {
|
|
|
|
'entry_points': {
|
|
|
|
'console_scripts': [
|
|
|
|
'virtualenv=virtualenv:main',
|
|
|
|
'virtualenv-%s.%s=virtualenv:main' % sys.version_info[:2]
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'zip_safe': False,
|
2014-12-23 18:26:10 +00:00
|
|
|
'cmdclass': {'test': PyTest},
|
|
|
|
'tests_require': ['pytest', 'mock'],
|
2012-06-29 01:34:05 +00:00
|
|
|
}
|
2010-06-01 20:45:04 +00:00
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup
|
|
|
|
if sys.platform == 'win32':
|
2014-12-23 18:26:10 +00:00
|
|
|
print('Note: without Setuptools installed you will '
|
|
|
|
'have to use "python -m virtualenv ENV"')
|
2012-06-29 01:34:05 +00:00
|
|
|
setup_params = {}
|
2010-06-01 20:45:04 +00:00
|
|
|
else:
|
2012-06-29 01:34:05 +00:00
|
|
|
script = 'scripts/virtualenv'
|
|
|
|
script_ver = script + '-%s.%s' % sys.version_info[:2]
|
|
|
|
shutil.copy(script, script_ver)
|
|
|
|
setup_params = {'scripts': [script, script_ver]}
|
2010-06-01 20:45:04 +00:00
|
|
|
|
|
|
|
|
2014-12-23 18:26:10 +00:00
|
|
|
def read_file(*paths):
|
|
|
|
here = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
with open(os.path.join(here, *paths)) as f:
|
|
|
|
return f.read()
|
|
|
|
|
|
|
|
# Get long_description from index.rst:
|
|
|
|
long_description = read_file('docs', 'index.rst')
|
|
|
|
long_description = long_description.strip().split('split here', 1)[0]
|
|
|
|
# Add release history
|
|
|
|
long_description += "\n\n" + read_file('docs', 'changes.rst')
|
2010-06-01 20:45:04 +00:00
|
|
|
|
2012-06-29 01:34:05 +00:00
|
|
|
|
|
|
|
def get_version():
|
2014-12-23 18:26:10 +00:00
|
|
|
version_file = read_file('virtualenv.py')
|
2012-06-29 01:34:05 +00:00
|
|
|
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
|
|
|
|
version_file, re.M)
|
|
|
|
if version_match:
|
|
|
|
return version_match.group(1)
|
|
|
|
raise RuntimeError("Unable to find version string.")
|
|
|
|
|
|
|
|
|
|
|
|
# Hack to prevent stupid TypeError: 'NoneType' object is not callable error on
|
|
|
|
# exit of python setup.py test # in multiprocessing/util.py _exit_function when
|
|
|
|
# running python setup.py test (see
|
|
|
|
# http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html)
|
|
|
|
try:
|
2014-12-23 18:26:10 +00:00
|
|
|
import multiprocessing # noqa
|
2012-06-29 01:34:05 +00:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name='virtualenv',
|
|
|
|
version=get_version(),
|
|
|
|
description="Virtual Python Environment builder",
|
|
|
|
long_description=long_description,
|
|
|
|
classifiers=[
|
2013-09-11 00:07:12 +00:00
|
|
|
'Development Status :: 5 - Production/Stable',
|
2010-06-01 20:45:04 +00:00
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
2012-04-25 17:37:16 +00:00
|
|
|
'Programming Language :: Python :: 2',
|
|
|
|
'Programming Language :: Python :: 2.6',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Programming Language :: Python :: 3.1',
|
|
|
|
'Programming Language :: Python :: 3.2',
|
2012-06-29 01:34:05 +00:00
|
|
|
],
|
|
|
|
keywords='setuptools deployment installation distutils',
|
|
|
|
author='Ian Bicking',
|
|
|
|
author_email='ianb@colorstudy.com',
|
|
|
|
maintainer='Jannis Leidel, Carl Meyer and Brian Rosner',
|
|
|
|
maintainer_email='python-virtualenv@groups.google.com',
|
2014-12-23 18:26:10 +00:00
|
|
|
url='https://virtualenv.pypa.io/',
|
2012-06-29 01:34:05 +00:00
|
|
|
license='MIT',
|
|
|
|
py_modules=['virtualenv'],
|
|
|
|
packages=['virtualenv_support'],
|
2014-04-11 19:07:20 +00:00
|
|
|
package_data={'virtualenv_support': ['*.whl']},
|
2012-06-29 01:34:05 +00:00
|
|
|
**setup_params)
|