setup.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #!/usr/bin/env python
  2. from __future__ import absolute_import, print_function
  3. import os
  4. import os.path
  5. import sys
  6. try:
  7. from setuptools import setup
  8. except ImportError:
  9. from distutils.core import setup
  10. if sys.argv[-1] == 'publish':
  11. os.system('python setup.py sdist upload')
  12. sys.exit()
  13. NAME = "future"
  14. PACKAGES = ["future",
  15. "future.builtins",
  16. "future.types",
  17. "future.standard_library",
  18. "future.backports",
  19. "future.backports.email",
  20. "future.backports.email.mime",
  21. "future.backports.html",
  22. "future.backports.http",
  23. "future.backports.test",
  24. "future.backports.urllib",
  25. "future.backports.xmlrpc",
  26. "future.moves",
  27. "future.moves.dbm",
  28. "future.moves.html",
  29. "future.moves.http",
  30. "future.moves.test",
  31. "future.moves.tkinter",
  32. "future.moves.urllib",
  33. "future.moves.xmlrpc",
  34. "future.tests", # for future.tests.base
  35. # "future.tests.test_email",
  36. "future.utils",
  37. "past",
  38. "past.builtins",
  39. "past.types",
  40. "past.utils",
  41. # "past.tests",
  42. "past.translation",
  43. "libfuturize",
  44. "libfuturize.fixes",
  45. "libpasteurize",
  46. "libpasteurize.fixes",
  47. ]
  48. # PEP 3108 stdlib moves:
  49. if sys.version_info[:2] < (3, 0):
  50. PACKAGES += [
  51. "builtins",
  52. # "configparser", # removed in v0.16.0
  53. "copyreg",
  54. "html",
  55. "http",
  56. "queue",
  57. "reprlib",
  58. "socketserver",
  59. "tkinter",
  60. "winreg",
  61. "xmlrpc",
  62. "_dummy_thread",
  63. "_markupbase",
  64. "_thread",
  65. ]
  66. PACKAGE_DATA = {'': [
  67. 'README.rst',
  68. 'LICENSE.txt',
  69. 'futurize.py',
  70. 'pasteurize.py',
  71. 'discover_tests.py',
  72. 'check_rst.sh',
  73. 'TESTING.txt',
  74. ],
  75. 'tests': ['*.py'],
  76. }
  77. REQUIRES = []
  78. TEST_REQUIRES = []
  79. if sys.version_info[:2] == (2, 6):
  80. REQUIRES += ['importlib', 'argparse']
  81. TEST_REQUIRES += ['unittest2']
  82. import src.future
  83. VERSION = src.future.__version__
  84. DESCRIPTION = "Clean single-source support for Python 3 and 2"
  85. LONG_DESC = src.future.__doc__
  86. AUTHOR = "Ed Schofield"
  87. AUTHOR_EMAIL = "ed@pythoncharmers.com"
  88. URL="https://python-future.org"
  89. LICENSE = "MIT"
  90. KEYWORDS = "future past python3 migration futurize backport six 2to3 modernize pasteurize 3to2"
  91. CLASSIFIERS = [
  92. "Programming Language :: Python",
  93. "Programming Language :: Python :: 2.6",
  94. "Programming Language :: Python :: 2.7",
  95. "Programming Language :: Python :: 3",
  96. "Programming Language :: Python :: 3.3",
  97. "Programming Language :: Python :: 3.4",
  98. "Programming Language :: Python :: 3.5",
  99. "License :: OSI Approved",
  100. "License :: OSI Approved :: MIT License",
  101. "Development Status :: 4 - Beta",
  102. "Intended Audience :: Developers",
  103. ]
  104. setup_kwds = {}
  105. # * Important *
  106. # We forcibly remove the build folder to avoid breaking the
  107. # user's Py3 installation if they run "python2 setup.py
  108. # build" and then "python3 setup.py install".
  109. try:
  110. # If the user happens to run:
  111. # python2 setup.py build
  112. # python3 setup.py install
  113. # then folders like "copyreg" will be in build/lib.
  114. # If so, we CANNOT let the user install this, because
  115. # this may break his/her Python 3 install, depending on the folder order in
  116. # sys.path. (Running "import html" etc. may pick up our Py2
  117. # substitute packages, instead of the intended system stdlib modules.)
  118. SYSTEM_MODULES = set([
  119. '_dummy_thread',
  120. '_markupbase',
  121. '_thread',
  122. 'builtins',
  123. # Catch the case that configparser is in the build folder
  124. # from a previous version of `future`:
  125. 'configparser',
  126. 'copyreg',
  127. 'html',
  128. 'http',
  129. 'queue',
  130. 'reprlib',
  131. 'socketserver',
  132. 'tkinter',
  133. 'winreg',
  134. 'xmlrpc'
  135. ])
  136. if sys.version_info[0] >= 3:
  137. # Do any of the above folders exist in build/lib?
  138. files = os.listdir(os.path.join('build', 'lib'))
  139. if len(set(files) & set(SYSTEM_MODULES)) > 0:
  140. print('ERROR: Your build folder is in an inconsistent state for '
  141. 'a Python 3.x install. Please remove it manually and run '
  142. 'setup.py again.', file=sys.stderr)
  143. sys.exit(1)
  144. except OSError:
  145. pass
  146. setup(name=NAME,
  147. version=VERSION,
  148. author=AUTHOR,
  149. author_email=AUTHOR_EMAIL,
  150. url=URL,
  151. description=DESCRIPTION,
  152. long_description=LONG_DESC,
  153. license=LICENSE,
  154. keywords=KEYWORDS,
  155. entry_points={
  156. 'console_scripts': [
  157. 'futurize = libfuturize.main:main',
  158. 'pasteurize = libpasteurize.main:main'
  159. ]
  160. },
  161. package_dir={'': 'src'},
  162. packages=PACKAGES,
  163. package_data=PACKAGE_DATA,
  164. include_package_data=True,
  165. install_requires=REQUIRES,
  166. classifiers=CLASSIFIERS,
  167. test_suite = "discover_tests",
  168. tests_require=TEST_REQUIRES,
  169. **setup_kwds
  170. )