setup.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2004-2007 Zope Corporation 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. """Setup for zope.interface package
  15. $Id: setup.py 101374 2009-07-01 15:55:00Z fdrake $
  16. """
  17. import os, sys
  18. from distutils.errors import (CCompilerError, DistutilsExecError,
  19. DistutilsPlatformError)
  20. try:
  21. from setuptools import setup, Extension, Feature
  22. from setuptools.command.build_ext import build_ext
  23. except ImportError, e:
  24. # do we need to support plain distutils for building when even
  25. # the package itself requires setuptools for installing?
  26. from distutils.core import setup, Extension
  27. from distutils.command.build_ext import build_ext
  28. if sys.version_info[:2] >= (2, 4):
  29. extra = dict(
  30. package_data={
  31. 'zope.interface': ['*.txt'],
  32. 'zope.interface.tests': ['*.txt'],
  33. }
  34. )
  35. else:
  36. extra = {}
  37. else:
  38. codeoptimization = Feature("Optional code optimizations",
  39. standard = True,
  40. ext_modules = [Extension(
  41. "zope.interface._zope_interface_coptimizations",
  42. [os.path.normcase(
  43. os.path.join('src', 'zope',
  44. 'interface',
  45. '_zope_interface_coptimizations.c')
  46. )]
  47. )])
  48. extra = dict(
  49. namespace_packages=["zope"],
  50. include_package_data = True,
  51. zip_safe = False,
  52. tests_require = ['zope.testing'],
  53. install_requires = ['setuptools'],
  54. extras_require={'docs': ['z3c.recipe.sphinxdoc']},
  55. features = {'codeoptimization': codeoptimization}
  56. )
  57. def read(*rnames):
  58. return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
  59. long_description=(
  60. read('README.txt')
  61. + '\n' +
  62. 'Detailed Documentation\n'
  63. '**********************\n'
  64. + '\n.. contents::\n\n' +
  65. read('src', 'zope', 'interface', 'README.txt')
  66. + '\n' +
  67. read('src', 'zope', 'interface', 'adapter.txt')
  68. + '\n' +
  69. read('src', 'zope', 'interface', 'human.txt')
  70. + '\n' +
  71. read('CHANGES.txt')
  72. + '\n' +
  73. 'Download\n'
  74. '********\n'
  75. )
  76. class optional_build_ext(build_ext):
  77. """This class subclasses build_ext and allows
  78. the building of C extensions to fail.
  79. """
  80. def run(self):
  81. try:
  82. build_ext.run(self)
  83. except DistutilsPlatformError, e:
  84. self._unavailable(e)
  85. def build_extension(self, ext):
  86. try:
  87. build_ext.build_extension(self, ext)
  88. except (CCompilerError, DistutilsExecError), e:
  89. self._unavailable(e)
  90. def _unavailable(self, e):
  91. print >> sys.stderr, '*' * 80
  92. print >> sys.stderr, """WARNING:
  93. An optional code optimization (C extension) could not be compiled.
  94. Optimizations for this package will not be available!"""
  95. print >> sys.stderr
  96. print >> sys.stderr, e
  97. print >> sys.stderr, '*' * 80
  98. setup(name='zope.interface',
  99. version = '3.5.2',
  100. url='http://pypi.python.org/pypi/zope.interface',
  101. license='ZPL 2.1',
  102. description='Interfaces for Python',
  103. author='Zope Corporation and Contributors',
  104. author_email='zope-dev@zope.org',
  105. long_description=long_description,
  106. packages = ['zope', 'zope.interface'],
  107. package_dir = {'': 'src'},
  108. cmdclass = {'build_ext': optional_build_ext},
  109. **extra)