Commit 849d829a authored by scoder's avatar scoder Committed by GitHub

Merge pull request #1456 from robertwb/distutils

Replace old build_ext with new cythonize(...) version.
parents ae7b046b 87e72124
...@@ -59,7 +59,9 @@ Other changes ...@@ -59,7 +59,9 @@ Other changes
the current jupyter kernel. The language level can be set explicitly with the current jupyter kernel. The language level can be set explicitly with
"%%cython -2" or "%%cython -3". "%%cython -2" or "%%cython -3".
* Usage of ``Cython.Distutils.build_ext`` is now discouraged. * The distutils extension ``Cython.Distutils.build_ext`` has now been updated
to use cythonize which properly handles dependencies. The old extension can
still be found in ``Cython.Distutils.old_build_ext`` and is now deprecated.
0.24.1 (2016-07-15) 0.24.1 (2016-07-15)
......
...@@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function ...@@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function
import cython import cython
from .. import __version__ from .. import __version__
import collections
import re, os, sys, time import re, os, sys, time
from glob import iglob from glob import iglob
...@@ -642,7 +643,9 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet= ...@@ -642,7 +643,9 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet=
print('Please put "# distutils: language=%s" in your .pyx or .pxd file(s)' % language) print('Please put "# distutils: language=%s" in your .pyx or .pxd file(s)' % language)
if exclude is None: if exclude is None:
exclude = [] exclude = []
if not isinstance(patterns, (list, tuple)): if patterns is None:
return [], {}
elif isinstance(patterns, basestring) or not isinstance(patterns, collections.Iterable):
patterns = [patterns] patterns = [patterns]
explicit_modules = set([m.name for m in patterns if isinstance(m, Extension)]) explicit_modules = set([m.name for m in patterns if isinstance(m, Extension)])
seen = set() seen = set()
......
import sys from Cython.Distutils.build_ext import build_ext
from .Dependencies import cythonize
if 'setuptools' in sys.modules:
from setuptools.command import build_ext as _build_ext
else:
from distutils.command import build_ext as _build_ext
class build_ext(_build_ext.build_ext, object):
def finalize_options(self):
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules)
super(build_ext, self).finalize_options()
...@@ -14,7 +14,7 @@ from distutils import ccompiler ...@@ -14,7 +14,7 @@ from distutils import ccompiler
import runtests import runtests
import Cython.Distutils.extension import Cython.Distutils.extension
import Cython.Distutils.build_ext import Cython.Distutils.old_build_ext as build_ext
from Cython.Debugger import Cygdb as cygdb from Cython.Debugger import Cygdb as cygdb
root = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.abspath(__file__))
...@@ -24,10 +24,6 @@ cfuncs_file = os.path.join(root, 'cfuncs.c') ...@@ -24,10 +24,6 @@ cfuncs_file = os.path.join(root, 'cfuncs.c')
with open(codefile) as f: with open(codefile) as f:
source_to_lineno = dict((line.strip(), i + 1) for i, line in enumerate(f)) source_to_lineno = dict((line.strip(), i + 1) for i, line in enumerate(f))
# Cython.Distutils.__init__ imports build_ext from build_ext which means we
# can't access the module anymore. Get it from sys.modules instead.
build_ext = sys.modules['Cython.Distutils.build_ext']
have_gdb = None have_gdb = None
def test_gdb(): def test_gdb():
......
This diff is collapsed.
This diff is collapsed.
...@@ -10,7 +10,7 @@ from distutils.errors import DistutilsArgError, DistutilsError, CCompilerError ...@@ -10,7 +10,7 @@ from distutils.errors import DistutilsArgError, DistutilsError, CCompilerError
from distutils.extension import Extension from distutils.extension import Extension
from distutils.util import grok_environment_error from distutils.util import grok_environment_error
try: try:
from Cython.Distutils import build_ext from Cython.Distutils.old_build_ext import old_build_ext as build_ext
HAS_CYTHON = True HAS_CYTHON = True
except ImportError: except ImportError:
HAS_CYTHON = False HAS_CYTHON = False
......
...@@ -5,10 +5,10 @@ PYTHON -c "import a; import sys; sys.exit(a.compile_env_test())" ...@@ -5,10 +5,10 @@ PYTHON -c "import a; import sys; sys.exit(a.compile_env_test())"
from distutils.core import setup from distutils.core import setup
from Cython.Distutils.extension import Extension from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext from Cython.Distutils.old_build_ext import old_build_ext
setup( setup(
cmdclass = {'build_ext': build_ext}, cmdclass = {'build_ext': old_build_ext},
ext_modules = [Extension( ext_modules = [Extension(
"a", ["a.pyx"], "a", ["a.pyx"],
pyrex_compile_time_env = {'TEST': True}, pyrex_compile_time_env = {'TEST': True},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment