setup.py 6.37 KB
Newer Older
PJ Eby's avatar
PJ Eby committed
1
#!/usr/bin/env python
Jason R. Coombs's avatar
Jason R. Coombs committed
2 3 4 5
"""
Distutils setup file, used to install or test 'setuptools'
"""

6
import io
7
import os
8
import sys
9
import textwrap
10

11 12 13
# Allow to run setup.py from another directory.
os.chdir(os.path.dirname(os.path.abspath(__file__)))

14 15
src_root = None

16 17
from distutils.util import convert_path

Jason R. Coombs's avatar
Jason R. Coombs committed
18
command_ns = {}
19
init_path = convert_path('setuptools/command/__init__.py')
20 21
with open(init_path) as init_file:
    exec(init_file.read(), command_ns)
22

Jason R. Coombs's avatar
Jason R. Coombs committed
23
SETUP_COMMANDS = command_ns['__all__']
24

25
import setuptools
26

27
scripts = []
28

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
def _gen_console_scripts():
    yield "easy_install = setuptools.command.easy_install:main"

    # Gentoo distributions manage the python-version-specific scripts
    # themselves, so those platforms define an environment variable to
    # suppress the creation of the version-specific scripts.
    var_names = (
        'SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
        'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
    )
    if any(os.environ.get(var) not in (None, "", "0") for var in var_names):
        return
    yield ("easy_install-{shortver} = setuptools.command.easy_install:main"
        .format(shortver=sys.version[:3]))

console_scripts = list(_gen_console_scripts())

46
readme_file = io.open('README.rst', encoding='utf-8')
47

48
with readme_file:
49
    long_description = readme_file.read()
50

51 52
package_data = {
        'setuptools': ['script (dev).tmpl', 'script.tmpl', 'site-patch.py']}
53 54 55 56
force_windows_specific_files = (
    os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES")
    not in (None, "", "0")
)
57 58
if (sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt')) \
        or force_windows_specific_files:
59 60 61
    package_data.setdefault('setuptools', []).extend(['*.exe'])
    package_data.setdefault('setuptools.command', []).extend(['*.xml'])

62
needs_pytest = set(['ptr', 'pytest', 'test']).intersection(sys.argv)
63
pytest_runner = ['pytest-runner'] if needs_pytest else []
64 65
needs_wheel = set(['release', 'bdist_wheel']).intersection(sys.argv)
wheel = ['wheel'] if needs_wheel else []
66

67
setup_params = dict(
68
    name="setuptools",
69
    version="23.1.0",
tarek's avatar
tarek committed
70 71
    description="Easily download, build, install, upgrade, and uninstall "
                "Python packages",
72
    author="Python Packaging Authority",
73
    author_email="distutils-sig@python.org",
Jason R. Coombs's avatar
Jason R. Coombs committed
74 75
    long_description=long_description,
    keywords="CPAN PyPI distutils eggs package management",
76
    url="https://github.com/pypa/setuptools",
Jason R. Coombs's avatar
Jason R. Coombs committed
77
    src_root=src_root,
78
    packages=setuptools.find_packages(exclude=['*.tests']),
Jason R. Coombs's avatar
Jason R. Coombs committed
79
    package_data=package_data,
80

81
    py_modules=['easy_install'],
82

Jason R. Coombs's avatar
Jason R. Coombs committed
83
    zip_safe=True,
84

Jason R. Coombs's avatar
Jason R. Coombs committed
85
    entry_points={
Jason R. Coombs's avatar
Jason R. Coombs committed
86
        "distutils.commands": [
87
            "%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals()
PJ Eby's avatar
PJ Eby committed
88
            for cmd in SETUP_COMMANDS
89
        ],
90
        "distutils.setup_keywords": [
91 92 93 94 95
            "eager_resources        = setuptools.dist:assert_string_list",
            "namespace_packages     = setuptools.dist:check_nsp",
            "extras_require         = setuptools.dist:check_extras",
            "install_requires       = setuptools.dist:check_requirements",
            "tests_require          = setuptools.dist:check_requirements",
Jason R. Coombs's avatar
Jason R. Coombs committed
96
            "setup_requires         = setuptools.dist:check_requirements",
97 98 99 100 101 102
            "entry_points           = setuptools.dist:check_entry_points",
            "test_suite             = setuptools.dist:check_test_suite",
            "zip_safe               = setuptools.dist:assert_bool",
            "package_data           = setuptools.dist:check_package_data",
            "exclude_package_data   = setuptools.dist:check_package_data",
            "include_package_data   = setuptools.dist:assert_bool",
103
            "packages               = setuptools.dist:check_packages",
104 105
            "dependency_links       = setuptools.dist:assert_string_list",
            "test_loader            = setuptools.dist:check_importable",
106
            "test_runner            = setuptools.dist:check_importable",
107 108
            "use_2to3               = setuptools.dist:assert_bool",
            "convert_2to3_doctests  = setuptools.dist:assert_string_list",
109 110
            "use_2to3_fixers        = setuptools.dist:assert_string_list",
            "use_2to3_exclude_fixers = setuptools.dist:assert_string_list",
111 112 113 114 115
        ],
        "egg_info.writers": [
            "PKG-INFO = setuptools.command.egg_info:write_pkg_info",
            "requires.txt = setuptools.command.egg_info:write_requirements",
            "entry_points.txt = setuptools.command.egg_info:write_entries",
116 117
            "eager_resources.txt = setuptools.command.egg_info:overwrite_arg",
            "namespace_packages.txt = setuptools.command.egg_info:overwrite_arg",
118 119
            "top_level.txt = setuptools.command.egg_info:write_toplevel_names",
            "depends.txt = setuptools.command.egg_info:warn_depends_obsolete",
120
            "dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
121
        ],
122
        "console_scripts": console_scripts,
123

124 125
        "setuptools.installation":
            ['eggsecutable = setuptools.command.easy_install:bootstrap'],
126
    },
127

128

Jason R. Coombs's avatar
Jason R. Coombs committed
129
    classifiers=textwrap.dedent("""
130 131
        Development Status :: 5 - Production/Stable
        Intended Audience :: Developers
132
        License :: OSI Approved :: MIT License
133
        Operating System :: OS Independent
134 135
        Programming Language :: Python :: 2.6
        Programming Language :: Python :: 2.7
136
        Programming Language :: Python :: 3
137
        Programming Language :: Python :: 3.3
138
        Programming Language :: Python :: 3.4
139
        Programming Language :: Python :: 3.5
140 141 142 143 144
        Topic :: Software Development :: Libraries :: Python Modules
        Topic :: System :: Archiving :: Packaging
        Topic :: System :: Systems Administration
        Topic :: Utilities
        """).strip().splitlines(),
Jason R. Coombs's avatar
Jason R. Coombs committed
145
    extras_require={
146
        "ssl:sys_platform=='win32'": "wincertstore==0.2",
Gabi Davar's avatar
Gabi Davar committed
147
        "certs": "certifi==2016.2.28",
148
    },
Jason R. Coombs's avatar
Jason R. Coombs committed
149
    dependency_links=[
Gabi Davar's avatar
Gabi Davar committed
150
        'https://pypi.python.org/packages/source/c/certifi/certifi-2016.2.28.tar.gz#md5=5d672aa766e1f773c75cfeccd02d3650',
151
        'https://pypi.python.org/packages/source/w/wincertstore/wincertstore-0.2.zip#md5=ae728f2f007185648d0c7a8679b361e2',
152
    ],
Jason R. Coombs's avatar
Jason R. Coombs committed
153 154
    scripts=[],
    tests_require=[
155
        'setuptools[ssl]',
Jason R. Coombs's avatar
Jason R. Coombs committed
156
        'pytest>=2.8',
157
    ] + (['mock'] if sys.version_info[:2] < (3, 3) else []),
Jason R. Coombs's avatar
Jason R. Coombs committed
158
    setup_requires=[
159
    ] + pytest_runner + wheel,
PJ Eby's avatar
PJ Eby committed
160
)
161 162

if __name__ == '__main__':
163
    dist = setuptools.setup(**setup_params)