summaryrefslogtreecommitdiff
path: root/setup.py
blob: d543d667c49f53eac2f132b4e1cd264818f98791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import os
import re
import sys

if sys.version_info[:2] < (2, 7):
    sys.exit("virtualenv requires Python 2.7 or higher.")
try:
    from setuptools import setup, find_packages
    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 = []

        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

            sys.exit(pytest.main(self.pytest_args))

    setup_params = {
        "entry_points": {"console_scripts": ["virtualenv=virtualenv:main"]},
        "zip_safe": False,
        "cmdclass": {"test": PyTest},
        "tests_require": ["pytest", "mock"],
    }
except ImportError:
    from distutils.core import setup

    if sys.platform == "win32":
        print("Note: without Setuptools installed you will " 'have to use "python -m virtualenv ENV"')
        setup_params = {}
    else:
        script = "src/scripts/virtualenv"
        setup_params = {"scripts": [script]}


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_full = read_file("docs", "index.rst")
long_description = long_description_full.strip().split("split here", 1)[0]
long_description += "\n\n`Read the changelog here <https://virtualenv.pypa.io/en/latest/changes.html>`_."


def get_version():
    version_file = read_file(os.path.join("src", "virtualenv.py"))
    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:
    import multiprocessing  # noqa
except ImportError:
    pass

setup(
    name="virtualenv",
    version=get_version(),
    description="Virtual Python Environment builder",
    long_description=long_description,
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 2",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.4",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
    ],
    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",
    url="https://virtualenv.pypa.io/",
    license="MIT",
    package_dir={"": "src"},
    py_modules=["virtualenv"],
    packages=find_packages("src"),
    package_data={"virtualenv_support": ["*.whl"]},
    python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
    extras_require={
        "testing": [
            'mock;python_version<"3.3"',
            "pytest >= 4.0.0, <5",
            "coverage >= 4.5.0, <5",
            'pytest-timeout >= 1.3.0, <2; platform_python_implementation!="Jython"',
            'xonsh; python_version>="3.4"',
            "six >= 1.10.0, < 2",
        ],
        "docs": ["sphinx >= 1.8.0, < 2", "towncrier >= 18.5.0"],
    },
    **setup_params
)