setup.py 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/usr/bin/env python
  2. """
  3. Distutils setup file, used to install or test 'setuptools'
  4. """
  5. import io
  6. import os
  7. import sys
  8. import textwrap
  9. # Allow to run setup.py from another directory.
  10. os.chdir(os.path.dirname(os.path.abspath(__file__)))
  11. src_root = None
  12. from distutils.util import convert_path
  13. command_ns = {}
  14. init_path = convert_path('setuptools/command/__init__.py')
  15. with open(init_path) as init_file:
  16. exec(init_file.read(), command_ns)
  17. SETUP_COMMANDS = command_ns['__all__']
  18. import setuptools
  19. scripts = []
  20. def _gen_console_scripts():
  21. yield "easy_install = setuptools.command.easy_install:main"
  22. # Gentoo distributions manage the python-version-specific scripts
  23. # themselves, so those platforms define an environment variable to
  24. # suppress the creation of the version-specific scripts.
  25. var_names = (
  26. 'SETUPTOOLS_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
  27. 'DISTRIBUTE_DISABLE_VERSIONED_EASY_INSTALL_SCRIPT',
  28. )
  29. if any(os.environ.get(var) not in (None, "", "0") for var in var_names):
  30. return
  31. yield ("easy_install-{shortver} = setuptools.command.easy_install:main"
  32. .format(shortver=sys.version[:3]))
  33. console_scripts = list(_gen_console_scripts())
  34. readme_file = io.open('README.rst', encoding='utf-8')
  35. with readme_file:
  36. long_description = readme_file.read()
  37. package_data = {
  38. 'setuptools': ['script (dev).tmpl', 'script.tmpl', 'site-patch.py']}
  39. force_windows_specific_files = (
  40. os.environ.get("SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES")
  41. not in (None, "", "0")
  42. )
  43. if (sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt')) \
  44. or force_windows_specific_files:
  45. package_data.setdefault('setuptools', []).extend(['*.exe'])
  46. package_data.setdefault('setuptools.command', []).extend(['*.xml'])
  47. needs_pytest = set(['ptr', 'pytest', 'test']).intersection(sys.argv)
  48. pytest_runner = ['pytest-runner'] if needs_pytest else []
  49. needs_wheel = set(['release', 'bdist_wheel']).intersection(sys.argv)
  50. wheel = ['wheel'] if needs_wheel else []
  51. setup_params = dict(
  52. name="setuptools",
  53. version="24.0.2",
  54. description="Easily download, build, install, upgrade, and uninstall "
  55. "Python packages",
  56. author="Python Packaging Authority",
  57. author_email="distutils-sig@python.org",
  58. long_description=long_description,
  59. keywords="CPAN PyPI distutils eggs package management",
  60. url="https://github.com/pypa/setuptools",
  61. src_root=src_root,
  62. packages=setuptools.find_packages(exclude=['*.tests']),
  63. package_data=package_data,
  64. py_modules=['easy_install'],
  65. zip_safe=True,
  66. entry_points={
  67. "distutils.commands": [
  68. "%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals()
  69. for cmd in SETUP_COMMANDS
  70. ],
  71. "distutils.setup_keywords": [
  72. "eager_resources = setuptools.dist:assert_string_list",
  73. "namespace_packages = setuptools.dist:check_nsp",
  74. "extras_require = setuptools.dist:check_extras",
  75. "install_requires = setuptools.dist:check_requirements",
  76. "tests_require = setuptools.dist:check_requirements",
  77. "setup_requires = setuptools.dist:check_requirements",
  78. "entry_points = setuptools.dist:check_entry_points",
  79. "test_suite = setuptools.dist:check_test_suite",
  80. "zip_safe = setuptools.dist:assert_bool",
  81. "package_data = setuptools.dist:check_package_data",
  82. "exclude_package_data = setuptools.dist:check_package_data",
  83. "include_package_data = setuptools.dist:assert_bool",
  84. "packages = setuptools.dist:check_packages",
  85. "dependency_links = setuptools.dist:assert_string_list",
  86. "test_loader = setuptools.dist:check_importable",
  87. "test_runner = setuptools.dist:check_importable",
  88. "use_2to3 = setuptools.dist:assert_bool",
  89. "convert_2to3_doctests = setuptools.dist:assert_string_list",
  90. "use_2to3_fixers = setuptools.dist:assert_string_list",
  91. "use_2to3_exclude_fixers = setuptools.dist:assert_string_list",
  92. ],
  93. "egg_info.writers": [
  94. "PKG-INFO = setuptools.command.egg_info:write_pkg_info",
  95. "requires.txt = setuptools.command.egg_info:write_requirements",
  96. "entry_points.txt = setuptools.command.egg_info:write_entries",
  97. "eager_resources.txt = setuptools.command.egg_info:overwrite_arg",
  98. "namespace_packages.txt = setuptools.command.egg_info:overwrite_arg",
  99. "top_level.txt = setuptools.command.egg_info:write_toplevel_names",
  100. "depends.txt = setuptools.command.egg_info:warn_depends_obsolete",
  101. "dependency_links.txt = setuptools.command.egg_info:overwrite_arg",
  102. ],
  103. "console_scripts": console_scripts,
  104. "setuptools.installation":
  105. ['eggsecutable = setuptools.command.easy_install:bootstrap'],
  106. },
  107. classifiers=textwrap.dedent("""
  108. Development Status :: 5 - Production/Stable
  109. Intended Audience :: Developers
  110. License :: OSI Approved :: MIT License
  111. Operating System :: OS Independent
  112. Programming Language :: Python :: 2.6
  113. Programming Language :: Python :: 2.7
  114. Programming Language :: Python :: 3
  115. Programming Language :: Python :: 3.3
  116. Programming Language :: Python :: 3.4
  117. Programming Language :: Python :: 3.5
  118. Topic :: Software Development :: Libraries :: Python Modules
  119. Topic :: System :: Archiving :: Packaging
  120. Topic :: System :: Systems Administration
  121. Topic :: Utilities
  122. """).strip().splitlines(),
  123. extras_require={
  124. "ssl:sys_platform=='win32'": "wincertstore==0.2",
  125. "certs": "certifi==2016.2.28",
  126. },
  127. dependency_links=[
  128. 'https://pypi.python.org/packages/source/c/certifi/certifi-2016.2.28.tar.gz#md5=5d672aa766e1f773c75cfeccd02d3650',
  129. 'https://pypi.python.org/packages/source/w/wincertstore/wincertstore-0.2.zip#md5=ae728f2f007185648d0c7a8679b361e2',
  130. ],
  131. scripts=[],
  132. tests_require=[
  133. 'setuptools[ssl]',
  134. 'pytest>=2.8',
  135. ] + (['mock'] if sys.version_info[:2] < (3, 3) else []),
  136. setup_requires=[
  137. ] + pytest_runner + wheel,
  138. )
  139. if __name__ == '__main__':
  140. dist = setuptools.setup(**setup_params)