setup.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2004-2007 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE.
  12. #
  13. ##############################################################################
  14. # This package is developed by the Zope Toolkit project, documented here:
  15. # http://docs.zope.org/zopetoolkit
  16. # When developing and releasing this package, please follow the documented
  17. # Zope Toolkit policies as described by this documentation.
  18. ##############################################################################
  19. """Setup for zope.interface package
  20. """
  21. import os
  22. import platform
  23. import sys
  24. from setuptools import setup, Extension, Feature
  25. from setuptools.command.build_ext import build_ext
  26. from setuptools import find_packages
  27. from distutils.errors import CCompilerError
  28. from distutils.errors import DistutilsExecError
  29. from distutils.errors import DistutilsPlatformError
  30. class optional_build_ext(build_ext):
  31. """This class subclasses build_ext and allows
  32. the building of C extensions to fail.
  33. """
  34. def run(self):
  35. try:
  36. build_ext.run(self)
  37. except DistutilsPlatformError as e:
  38. self._unavailable(e)
  39. def build_extension(self, ext):
  40. try:
  41. build_ext.build_extension(self, ext)
  42. except (CCompilerError, DistutilsExecError, OSError) as e:
  43. self._unavailable(e)
  44. def _unavailable(self, e):
  45. print('*' * 80)
  46. print("""WARNING:
  47. An optional code optimization (C extension) could not be compiled.
  48. Optimizations for this package will not be available!""")
  49. print()
  50. print(e)
  51. print('*' * 80)
  52. codeoptimization_c = os.path.join('src', 'zope', 'interface',
  53. '_zope_interface_coptimizations.c')
  54. codeoptimization = Feature(
  55. "Optional code optimizations",
  56. standard=True,
  57. ext_modules=[
  58. Extension(
  59. "zope.interface._zope_interface_coptimizations",
  60. [os.path.normcase(codeoptimization_c)]
  61. )
  62. ])
  63. py_impl = getattr(platform, 'python_implementation', lambda: None)
  64. is_pypy = py_impl() == 'PyPy'
  65. is_jython = 'java' in sys.platform
  66. is_pure = 'PURE_PYTHON' in os.environ
  67. # Jython cannot build the C optimizations, while on PyPy they are
  68. # anti-optimizations (the C extension compatibility layer is known-slow,
  69. # and defeats JIT opportunities).
  70. if is_pypy or is_jython or is_pure:
  71. features = {}
  72. else:
  73. features = {'codeoptimization': codeoptimization}
  74. tests_require = ['zope.event']
  75. testing_extras = tests_require + ['nose', 'coverage']
  76. def read(*rnames):
  77. with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
  78. return f.read()
  79. long_description=(
  80. read('README.rst')
  81. + '\n' +
  82. read('CHANGES.rst')
  83. )
  84. setup(name='zope.interface',
  85. version='4.5.0',
  86. url='https://github.com/zopefoundation/zope.interface',
  87. license='ZPL 2.1',
  88. description='Interfaces for Python',
  89. author='Zope Foundation and Contributors',
  90. author_email='zope-dev@zope.org',
  91. long_description=long_description,
  92. classifiers=[
  93. "Development Status :: 5 - Production/Stable",
  94. "Intended Audience :: Developers",
  95. "License :: OSI Approved :: Zope Public License",
  96. "Operating System :: OS Independent",
  97. "Programming Language :: Python",
  98. "Programming Language :: Python :: 2",
  99. "Programming Language :: Python :: 2.7",
  100. "Programming Language :: Python :: 3",
  101. "Programming Language :: Python :: 3.4",
  102. "Programming Language :: Python :: 3.5",
  103. "Programming Language :: Python :: 3.6",
  104. "Programming Language :: Python :: Implementation :: CPython",
  105. "Programming Language :: Python :: Implementation :: PyPy",
  106. "Framework :: Zope3",
  107. "Topic :: Software Development :: Libraries :: Python Modules",
  108. ],
  109. packages=find_packages('src'),
  110. package_dir={'': 'src'},
  111. namespace_packages=["zope"],
  112. cmdclass={
  113. 'build_ext': optional_build_ext,
  114. },
  115. test_suite='zope.interface.tests',
  116. include_package_data=True,
  117. zip_safe=False,
  118. tests_require=tests_require,
  119. install_requires=['setuptools'],
  120. python_requires=', '.join((
  121. '>=2.7',
  122. '!=3.0.*',
  123. '!=3.1.*',
  124. '!=3.2.*',
  125. '!=3.3.*',
  126. )),
  127. extras_require={
  128. 'docs': ['Sphinx', 'repoze.sphinx.autointerface'],
  129. 'test': tests_require,
  130. 'testing': testing_extras,
  131. },
  132. features=features,
  133. keywords=['interface', 'components', 'plugins'],
  134. )