py-setuptools/setup.py

156 lines
5.8 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python
2015-03-04 17:10:44 +02:00
"""
Distutils setup file, used to install or test 'setuptools'
"""
import os
import sys
2016-07-23 20:26:53 +03:00
import setuptools
here = os.path.dirname(__file__)
def require_metadata():
"Prevent improper installs without necessary metadata. See #659"
egg_info_dir = os.path.join(here, 'setuptools.egg-info')
if not os.path.exists(egg_info_dir):
msg = (
"Cannot build setuptools without metadata. "
"Run `bootstrap.py`."
)
raise RuntimeError(msg)
2016-07-23 20:26:53 +03:00
def read_commands():
command_ns = {}
cmd_module_path = 'setuptools/command/__init__.py'
init_path = os.path.join(here, cmd_module_path)
2016-07-23 20:26:53 +03:00
with open(init_path) as init_file:
exec(init_file.read(), command_ns)
return command_ns['__all__']
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
2018-03-17 19:20:54 +02:00
tmpl = "easy_install-{shortver} = setuptools.command.easy_install:main"
2019-08-18 05:14:48 +03:00
yield tmpl.format(shortver='{}.{}'.format(*sys.version_info))
package_data = dict(
setuptools=['script (dev).tmpl', 'script.tmpl', 'site-patch.py'],
)
force_windows_specific_files = (
os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES", "1").lower()
not in ("", "0", "false", "no")
)
include_windows_files = (
sys.platform == 'win32' or
os.name == 'java' and os._name == 'nt' or
force_windows_specific_files
)
if include_windows_files:
package_data.setdefault('setuptools', []).extend(['*.exe'])
package_data.setdefault('setuptools.command', []).extend(['*.xml'])
needs_wheel = set(['release', 'bdist_wheel']).intersection(sys.argv)
wheel = ['wheel'] if needs_wheel else []
2016-07-24 05:33:26 +03:00
def pypi_link(pkg_filename):
"""
Given the filename, including md5 fragment, construct the
dependency link for PyPI.
"""
root = 'https://files.pythonhosted.org/packages/source'
name, sep, rest = pkg_filename.partition('-')
parts = root, name[0], name, pkg_filename
return '/'.join(parts)
2016-07-24 05:33:26 +03:00
2013-07-13 22:19:28 +03:00
setup_params = dict(
2016-07-23 20:35:41 +03:00
src_root=None,
2014-05-23 15:12:13 +03:00
package_data=package_data,
entry_points={
2013-07-18 16:10:24 +03:00
"distutils.commands": [
"%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals()
2016-07-23 20:26:53 +03:00
for cmd in read_commands()
],
"setuptools.finalize_distribution_options": [
"parent_finalize = setuptools.dist:_Distribution.finalize_options",
"features = setuptools.dist:Distribution._finalize_feature_opts",
"keywords = setuptools.dist:Distribution._finalize_setup_keywords",
"2to3_doctests = "
"setuptools.dist:Distribution._finalize_2to3_doctests",
],
"distutils.setup_keywords": [
"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",
2014-08-11 02:50:55 +03:00
"setup_requires = setuptools.dist:check_requirements",
"python_requires = setuptools.dist:check_specifier",
"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",
"packages = setuptools.dist:check_packages",
"dependency_links = setuptools.dist:assert_string_list",
"test_loader = setuptools.dist:check_importable",
"test_runner = setuptools.dist:check_importable",
"use_2to3 = setuptools.dist:assert_bool",
"convert_2to3_doctests = setuptools.dist:assert_string_list",
"use_2to3_fixers = setuptools.dist:assert_string_list",
"use_2to3_exclude_fixers = setuptools.dist:assert_string_list",
],
"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",
"eager_resources.txt = setuptools.command.egg_info:overwrite_arg",
2018-03-17 19:20:54 +02:00
(
"namespace_packages.txt = "
"setuptools.command.egg_info:overwrite_arg"
),
"top_level.txt = setuptools.command.egg_info:write_toplevel_names",
"depends.txt = setuptools.command.egg_info:warn_depends_obsolete",
"dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
],
2016-07-23 20:35:41 +03:00
"console_scripts": list(_gen_console_scripts()),
"setuptools.installation":
['eggsecutable = setuptools.command.easy_install:bootstrap'],
},
2014-05-23 15:12:13 +03:00
dependency_links=[
pypi_link(
2016-09-28 09:37:15 +03:00
'certifi-2016.9.26.tar.gz#md5=baa81e951a29958563689d868ef1064d',
),
pypi_link(
'wincertstore-0.2.zip#md5=ae728f2f007185648d0c7a8679b361e2',
),
],
2014-05-23 15:12:13 +03:00
setup_requires=[
2016-10-15 01:56:12 +03:00
] + wheel,
)
2013-07-13 22:19:28 +03:00
if __name__ == '__main__':
# allow setup.py to run from another directory
2016-07-25 16:38:51 +03:00
here and os.chdir(here)
require_metadata()
dist = setuptools.setup(**setup_params)