| OLD | NEW |
| (Empty) | |
| 1 import os |
| 2 import re |
| 3 import shutil |
| 4 import sys |
| 5 |
| 6 if sys.version_info[:2] < (2, 6): |
| 7 sys.exit('virtualenv requires Python 2.6 or higher.') |
| 8 |
| 9 try: |
| 10 from setuptools import setup |
| 11 from setuptools.command.test import test as TestCommand |
| 12 |
| 13 class PyTest(TestCommand): |
| 14 user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] |
| 15 |
| 16 def initialize_options(self): |
| 17 TestCommand.initialize_options(self) |
| 18 self.pytest_args = [] |
| 19 |
| 20 def finalize_options(self): |
| 21 TestCommand.finalize_options(self) |
| 22 #self.test_args = [] |
| 23 #self.test_suite = True |
| 24 |
| 25 def run_tests(self): |
| 26 # import here, because outside the eggs aren't loaded |
| 27 import pytest |
| 28 sys.exit(pytest.main(self.pytest_args)) |
| 29 |
| 30 setup_params = { |
| 31 'entry_points': { |
| 32 'console_scripts': ['virtualenv=virtualenv:main'], |
| 33 }, |
| 34 'zip_safe': False, |
| 35 'cmdclass': {'test': PyTest}, |
| 36 'tests_require': ['pytest', 'mock'], |
| 37 } |
| 38 except ImportError: |
| 39 from distutils.core import setup |
| 40 if sys.platform == 'win32': |
| 41 print('Note: without Setuptools installed you will ' |
| 42 'have to use "python -m virtualenv ENV"') |
| 43 setup_params = {} |
| 44 else: |
| 45 script = 'scripts/virtualenv' |
| 46 setup_params = {'scripts': [script]} |
| 47 |
| 48 |
| 49 def read_file(*paths): |
| 50 here = os.path.dirname(os.path.abspath(__file__)) |
| 51 with open(os.path.join(here, *paths)) as f: |
| 52 return f.read() |
| 53 |
| 54 # Get long_description from index.rst: |
| 55 long_description = read_file('docs', 'index.rst') |
| 56 long_description = long_description.strip().split('split here', 1)[0] |
| 57 # Add release history |
| 58 changes = read_file('docs', 'changes.rst') |
| 59 # Only report last two releases for brevity |
| 60 releases_found = 0 |
| 61 change_lines = [] |
| 62 for line in changes.splitlines(): |
| 63 change_lines.append(line) |
| 64 if line.startswith('--------------'): |
| 65 releases_found += 1 |
| 66 if releases_found > 2: |
| 67 break |
| 68 |
| 69 changes = '\n'.join(change_lines[:-2]) + '\n' |
| 70 changes += '`Full Changelog <https://virtualenv.pypa.io/en/latest/changes.html>`
_.' |
| 71 # Replace issue/pull directives |
| 72 changes = re.sub(r':pull:`(\d+)`', r'PR #\1', changes) |
| 73 changes = re.sub(r':issue:`(\d+)`', r'#\1', changes) |
| 74 |
| 75 long_description += '\n\n' + changes |
| 76 |
| 77 |
| 78 def get_version(): |
| 79 version_file = read_file('virtualenv.py') |
| 80 version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", |
| 81 version_file, re.M) |
| 82 if version_match: |
| 83 return version_match.group(1) |
| 84 raise RuntimeError("Unable to find version string.") |
| 85 |
| 86 |
| 87 # Hack to prevent stupid TypeError: 'NoneType' object is not callable error on |
| 88 # exit of python setup.py test # in multiprocessing/util.py _exit_function when |
| 89 # running python setup.py test (see |
| 90 # http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html) |
| 91 try: |
| 92 import multiprocessing # noqa |
| 93 except ImportError: |
| 94 pass |
| 95 |
| 96 setup( |
| 97 name='virtualenv', |
| 98 version=get_version(), |
| 99 description="Virtual Python Environment builder", |
| 100 long_description=long_description, |
| 101 classifiers=[ |
| 102 'Development Status :: 5 - Production/Stable', |
| 103 'Intended Audience :: Developers', |
| 104 'License :: OSI Approved :: MIT License', |
| 105 'Programming Language :: Python :: 2', |
| 106 'Programming Language :: Python :: 2.6', |
| 107 'Programming Language :: Python :: 2.7', |
| 108 'Programming Language :: Python :: 3', |
| 109 'Programming Language :: Python :: 3.3', |
| 110 'Programming Language :: Python :: 3.4', |
| 111 'Programming Language :: Python :: 3.5', |
| 112 ], |
| 113 keywords='setuptools deployment installation distutils', |
| 114 author='Ian Bicking', |
| 115 author_email='ianb@colorstudy.com', |
| 116 maintainer='Jannis Leidel, Carl Meyer and Brian Rosner', |
| 117 maintainer_email='python-virtualenv@groups.google.com', |
| 118 url='https://virtualenv.pypa.io/', |
| 119 license='MIT', |
| 120 py_modules=['virtualenv'], |
| 121 packages=['virtualenv_support'], |
| 122 package_data={'virtualenv_support': ['*.whl']}, |
| 123 **setup_params) |
| OLD | NEW |