Skip to content

Commit

Permalink
Make setuptools a hard dep of setup.py
Browse files Browse the repository at this point in the history
Fixes #13
Fixes #14
  • Loading branch information
jamadden committed Aug 4, 2016
1 parent b516fca commit 2081db2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 52 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,9 @@ Changes
be used together in ordered containers like BTrees.
(https://github.com/zopefoundation/zope.interface/issues/42)

- Make ``setuptools`` a hard dependency of ``setup.py``.
(https://github.com/zopefoundation/zope.interface/issues/13)

4.2.0 (2016-06-10)
------------------

Expand Down
98 changes: 46 additions & 52 deletions setup.py
Expand Up @@ -23,14 +23,14 @@
import platform
import sys

from setuptools import setup, Extension, Feature
from setuptools.command.build_ext import build_ext
from setuptools import find_packages

from distutils.errors import CCompilerError
from distutils.errors import DistutilsExecError
from distutils.errors import DistutilsPlatformError

try:
from setuptools.command.build_ext import build_ext
except ImportError:
from distutils.command.build_ext import build_ext

class optional_build_ext(build_ext):
"""This class subclasses build_ext and allows
Expand Down Expand Up @@ -59,49 +59,32 @@ def _unavailable(self, e):
print(e)
print('*' * 80)

try:
from setuptools import setup, Extension, Feature
except ImportError:
# do we need to support plain distutils for building when even
# the package itself requires setuptools for installing?
from distutils.core import setup, Extension
extra = {}
codeoptimization_c = os.path.join('src', 'zope', 'interface',
'_zope_interface_coptimizations.c')
codeoptimization = Feature(
"Optional code optimizations",
standard=True,
ext_modules=[
Extension(
"zope.interface._zope_interface_coptimizations",
[os.path.normcase(codeoptimization_c)]
)
])
py_impl = getattr(platform, 'python_implementation', lambda: None)
is_pypy = py_impl() == 'PyPy'
is_jython = 'java' in sys.platform
is_pure = 'PURE_PYTHON' in os.environ

# Jython cannot build the C optimizations, while on PyPy they are
# anti-optimizations (the C extension compatibility layer is known-slow,
# and defeats JIT opportunities).
if is_pypy or is_jython or is_pure:
features = {}
else:
codeoptimization_c = os.path.join('src', 'zope', 'interface',
'_zope_interface_coptimizations.c')
codeoptimization = Feature(
"Optional code optimizations",
standard = True,
ext_modules = [Extension(
"zope.interface._zope_interface_coptimizations",
[os.path.normcase(codeoptimization_c)]
)])
py_impl = getattr(platform, 'python_implementation', lambda: None)
is_pypy = py_impl() == 'PyPy'
is_jython = 'java' in sys.platform
is_pure = 'PURE_PYTHON' in os.environ
features = {'codeoptimization': codeoptimization}
tests_require = ['zope.event']
testing_extras = tests_require + ['nose', 'coverage']

# Jython cannot build the C optimizations, while on PyPy they are
# anti-optimizations (the C extension compatibility layer is known-slow,
# and defeats JIT opportunities).
if is_pypy or is_jython or is_pure:
features = {}
else:
features = {'codeoptimization': codeoptimization}
tests_require = ['zope.event']
testing_extras = tests_require + ['nose', 'coverage']
extra = dict(
namespace_packages=["zope"],
include_package_data = True,
zip_safe = False,
tests_require = tests_require,
install_requires = ['setuptools'],
extras_require={'docs': ['Sphinx', 'repoze.sphinx.autointerface'],
'test': tests_require,
'testing': testing_extras,
},
features = features
)

def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
Expand Down Expand Up @@ -138,10 +121,21 @@ def read(*rnames):
"Framework :: Zope3",
"Topic :: Software Development :: Libraries :: Python Modules",
],

packages = ['zope', 'zope.interface', 'zope.interface.tests'],
package_dir = {'': 'src'},
cmdclass = {'build_ext': optional_build_ext,
},
test_suite = 'zope.interface.tests',
**extra)
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=["zope"],
cmdclass={
'build_ext': optional_build_ext,
},
test_suite='zope.interface.tests',
include_package_data=True,
zip_safe=False,
tests_require=tests_require,
install_requires=['setuptools'],
extras_require={
'docs': ['Sphinx', 'repoze.sphinx.autointerface'],
'test': tests_require,
'testing': testing_extras,
},
features=features,
)

0 comments on commit 2081db2

Please sign in to comment.