aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt24
-rw-r--r--setuptools/command/build_ext.py15
-rw-r--r--setuptools/extension.py21
3 files changed, 37 insertions, 23 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 9ca376fa..5a1c7493 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,30 @@
CHANGES
=======
+----
+18.0
+----
+
+* Dropped support for builds with Pyrex. Only Cython is supported.
+* Issue #288: Detect Cython later in the build process, after
+ ``setup_requires`` dependencies are resolved.
+ Projects backed by Cython can now be readily built
+ with a ``setup_requires`` dependency. For example::
+
+ ext = setuptools.Extension('mylib', ['src/CythonStuff.pyx', 'src/CStuff.c'])
+ setuptools.setup(
+ ...
+ ext_modules=[ext],
+ setup_requires=['cython'],
+ )
+
+ For compatibility with older versions of setuptools, packagers should
+ still include ``src/CythonMod.c`` in the source distributions or
+ require that Cython be present before building source distributions.
+ However, for systems with this build of setuptools, Cython will be
+ downloaded on demand.
+
+
------
17.1.1
------
diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py
index e4b2c593..92e4a189 100644
--- a/setuptools/command/build_ext.py
+++ b/setuptools/command/build_ext.py
@@ -11,8 +11,8 @@ import itertools
from setuptools.extension import Library
try:
- # Attempt to use Pyrex for building extensions, if available
- from Pyrex.Distutils.build_ext import build_ext as _build_ext
+ # Attempt to use Cython for building extensions, if available
+ from Cython.Distutils.build_ext import build_ext as _build_ext
except ImportError:
_build_ext = _du_build_ext
@@ -42,7 +42,6 @@ elif os.name != 'nt':
if_dl = lambda s: s if have_rtld else ''
-
class build_ext(_build_ext):
def run(self):
"""Build extensions in build directory, then copy if --inplace"""
@@ -74,15 +73,6 @@ class build_ext(_build_ext):
if ext._needs_stub:
self.write_stub(package_dir or os.curdir, ext, True)
- if _build_ext is not _du_build_ext and not hasattr(_build_ext,
- 'pyrex_sources'):
- # Workaround for problems using some Pyrex versions w/SWIG and/or 2.4
- def swig_sources(self, sources, *otherargs):
- # first do any Pyrex processing
- sources = _build_ext.swig_sources(self, sources) or sources
- # Then do any actual SWIG stuff on the remainder
- return _du_build_ext.swig_sources(self, sources, *otherargs)
-
def get_ext_filename(self, fullname):
filename = _build_ext.get_ext_filename(self, fullname)
if fullname in self.ext_map:
@@ -176,6 +166,7 @@ class build_ext(_build_ext):
return _build_ext.get_export_symbols(self, ext)
def build_extension(self, ext):
+ ext._convert_pyx_sources_to_lang()
_compiler = self.compiler
try:
if isinstance(ext, Library):
diff --git a/setuptools/extension.py b/setuptools/extension.py
index 8178ed33..a7c40f86 100644
--- a/setuptools/extension.py
+++ b/setuptools/extension.py
@@ -12,35 +12,34 @@ _Extension = _get_unpatched(distutils.core.Extension)
msvc9_support.patch_for_specialized_compiler()
-def have_pyrex():
+def _have_cython():
"""
- Return True if Cython or Pyrex can be imported.
+ Return True if Cython can be imported.
"""
- pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext'
- for pyrex_impl in pyrex_impls:
+ cython_impls = 'Cython.Distutils.build_ext',
+ for cython_impl in cython_impls:
try:
- # from (pyrex_impl) import build_ext
- __import__(pyrex_impl, fromlist=['build_ext']).build_ext
+ # from (cython_impl) import build_ext
+ __import__(cython_impl, fromlist=['build_ext']).build_ext
return True
except Exception:
pass
return False
+# for compatibility
+have_pyrex = _have_cython
+
class Extension(_Extension):
"""Extension that uses '.c' files in place of '.pyx' files"""
- def __init__(self, *args, **kw):
- _Extension.__init__(self, *args, **kw)
- self._convert_pyx_sources_to_lang()
-
def _convert_pyx_sources_to_lang(self):
"""
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
"""
- if have_pyrex():
+ if _have_cython():
# the build has Cython, so allow it to compile the .pyx files
return
lang = self.language or ''