• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2"""
3Distutils setup file, used to install or test 'setuptools'
4"""
5
6import io
7import os
8import sys
9import textwrap
10
11import setuptools
12
13here = os.path.dirname(__file__)
14
15
16def require_metadata():
17    "Prevent improper installs without necessary metadata. See #659"
18    egg_info_dir = os.path.join(here, 'setuptools.egg-info')
19    if not os.path.exists(egg_info_dir):
20        msg = (
21            "Cannot build setuptools without metadata. "
22            "Run `bootstrap.py`."
23        )
24        raise RuntimeError(msg)
25
26
27def read_commands():
28    command_ns = {}
29    cmd_module_path = 'setuptools/command/__init__.py'
30    init_path = os.path.join(here, cmd_module_path)
31    with open(init_path) as init_file:
32        exec(init_file.read(), command_ns)
33    return command_ns['__all__']
34
35
36def _gen_console_scripts():
37    yield "easy_install = setuptools.command.easy_install:main"
38
39    # Gentoo distributions manage the python-version-specific scripts
40    # themselves, so those platforms define an environment variable to
41    # suppress the creation of the version-specific scripts.
42    var_names = (
43        'SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
44        'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
45    )
46    if any(os.environ.get(var) not in (None, "", "0") for var in var_names):
47        return
48    tmpl = "easy_install-{shortver} = setuptools.command.easy_install:main"
49    yield tmpl.format(shortver=sys.version[:3])
50
51
52readme_path = os.path.join(here, 'README.rst')
53with io.open(readme_path, encoding='utf-8') as readme_file:
54    long_description = readme_file.read()
55
56package_data = dict(
57    setuptools=['script (dev).tmpl', 'script.tmpl', 'site-patch.py'],
58)
59
60force_windows_specific_files = (
61    os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES", "1").lower()
62    not in ("", "0", "false", "no")
63)
64
65include_windows_files = (
66    sys.platform == 'win32' or
67    os.name == 'java' and os._name == 'nt' or
68    force_windows_specific_files
69)
70
71if include_windows_files:
72    package_data.setdefault('setuptools', []).extend(['*.exe'])
73    package_data.setdefault('setuptools.command', []).extend(['*.xml'])
74
75needs_wheel = set(['release', 'bdist_wheel']).intersection(sys.argv)
76wheel = ['wheel'] if needs_wheel else []
77
78
79def pypi_link(pkg_filename):
80    """
81    Given the filename, including md5 fragment, construct the
82    dependency link for PyPI.
83    """
84    root = 'https://files.pythonhosted.org/packages/source'
85    name, sep, rest = pkg_filename.partition('-')
86    parts = root, name[0], name, pkg_filename
87    return '/'.join(parts)
88
89
90setup_params = dict(
91    name="setuptools",
92    version="39.1.0",
93    description=(
94        "Easily download, build, install, upgrade, and uninstall "
95        "Python packages"
96    ),
97    author="Python Packaging Authority",
98    author_email="distutils-sig@python.org",
99    long_description=long_description,
100    long_description_content_type='text/x-rst; charset=UTF-8',
101    keywords="CPAN PyPI distutils eggs package management",
102    url="https://github.com/pypa/setuptools",
103    project_urls={
104        "Documentation": "https://setuptools.readthedocs.io/",
105    },
106    src_root=None,
107    packages=setuptools.find_packages(exclude=['*.tests']),
108    package_data=package_data,
109    py_modules=['easy_install'],
110    zip_safe=True,
111    entry_points={
112        "distutils.commands": [
113            "%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals()
114            for cmd in read_commands()
115        ],
116        "distutils.setup_keywords": [
117            "eager_resources        = setuptools.dist:assert_string_list",
118            "namespace_packages     = setuptools.dist:check_nsp",
119            "extras_require         = setuptools.dist:check_extras",
120            "install_requires       = setuptools.dist:check_requirements",
121            "tests_require          = setuptools.dist:check_requirements",
122            "setup_requires         = setuptools.dist:check_requirements",
123            "python_requires        = setuptools.dist:check_specifier",
124            "entry_points           = setuptools.dist:check_entry_points",
125            "test_suite             = setuptools.dist:check_test_suite",
126            "zip_safe               = setuptools.dist:assert_bool",
127            "package_data           = setuptools.dist:check_package_data",
128            "exclude_package_data   = setuptools.dist:check_package_data",
129            "include_package_data   = setuptools.dist:assert_bool",
130            "packages               = setuptools.dist:check_packages",
131            "dependency_links       = setuptools.dist:assert_string_list",
132            "test_loader            = setuptools.dist:check_importable",
133            "test_runner            = setuptools.dist:check_importable",
134            "use_2to3               = setuptools.dist:assert_bool",
135            "convert_2to3_doctests  = setuptools.dist:assert_string_list",
136            "use_2to3_fixers        = setuptools.dist:assert_string_list",
137            "use_2to3_exclude_fixers = setuptools.dist:assert_string_list",
138        ],
139        "egg_info.writers": [
140            "PKG-INFO = setuptools.command.egg_info:write_pkg_info",
141            "requires.txt = setuptools.command.egg_info:write_requirements",
142            "entry_points.txt = setuptools.command.egg_info:write_entries",
143            "eager_resources.txt = setuptools.command.egg_info:overwrite_arg",
144            (
145                "namespace_packages.txt = "
146                "setuptools.command.egg_info:overwrite_arg"
147            ),
148            "top_level.txt = setuptools.command.egg_info:write_toplevel_names",
149            "depends.txt = setuptools.command.egg_info:warn_depends_obsolete",
150            "dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
151        ],
152        "console_scripts": list(_gen_console_scripts()),
153        "setuptools.installation":
154            ['eggsecutable = setuptools.command.easy_install:bootstrap'],
155    },
156    classifiers=textwrap.dedent("""
157        Development Status :: 5 - Production/Stable
158        Intended Audience :: Developers
159        License :: OSI Approved :: MIT License
160        Operating System :: OS Independent
161        Programming Language :: Python :: 2
162        Programming Language :: Python :: 2.7
163        Programming Language :: Python :: 3
164        Programming Language :: Python :: 3.3
165        Programming Language :: Python :: 3.4
166        Programming Language :: Python :: 3.5
167        Programming Language :: Python :: 3.6
168        Topic :: Software Development :: Libraries :: Python Modules
169        Topic :: System :: Archiving :: Packaging
170        Topic :: System :: Systems Administration
171        Topic :: Utilities
172        """).strip().splitlines(),
173    python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*',
174    extras_require={
175        "ssl:sys_platform=='win32'": "wincertstore==0.2",
176        "certs": "certifi==2016.9.26",
177    },
178    dependency_links=[
179        pypi_link(
180            'certifi-2016.9.26.tar.gz#md5=baa81e951a29958563689d868ef1064d',
181        ),
182        pypi_link(
183            'wincertstore-0.2.zip#md5=ae728f2f007185648d0c7a8679b361e2',
184        ),
185    ],
186    scripts=[],
187    setup_requires=[
188    ] + wheel,
189)
190
191if __name__ == '__main__':
192    # allow setup.py to run from another directory
193    here and os.chdir(here)
194    require_metadata()
195    dist = setuptools.setup(**setup_params)
196