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
the current jupyter kernel. The language level can be set explicitly with
"%%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)
......
......@@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function
import cython
from .. import __version__
import collections
import re, os, sys, time
from glob import iglob
......@@ -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)
if exclude is None:
exclude = []
if not isinstance(patterns, (list, tuple)):
if patterns is None:
return [], {}
elif isinstance(patterns, basestring) or not isinstance(patterns, collections.Iterable):
patterns = [patterns]
explicit_modules = set([m.name for m in patterns if isinstance(m, Extension)])
seen = set()
......
import sys
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()
from Cython.Distutils.build_ext import build_ext
......@@ -14,7 +14,7 @@ from distutils import ccompiler
import runtests
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
root = os.path.dirname(os.path.abspath(__file__))
......@@ -24,10 +24,6 @@ cfuncs_file = os.path.join(root, 'cfuncs.c')
with open(codefile) as 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
def test_gdb():
......
This diff is collapsed.
This diff is collapsed.
......@@ -10,7 +10,7 @@ from distutils.errors import DistutilsArgError, DistutilsError, CCompilerError
from distutils.extension import Extension
from distutils.util import grok_environment_error
try:
from Cython.Distutils import build_ext
from Cython.Distutils.old_build_ext import old_build_ext as build_ext
HAS_CYTHON = True
except ImportError:
HAS_CYTHON = False
......@@ -22,7 +22,7 @@ _reloads={}
def pyx_to_dll(filename, ext=None, force_rebuild=0, build_in_temp=False, pyxbuild_dir=None,
setup_args=None, reload_support=False, inplace=False):
"""Compile a PYX file to a DLL and return the name of the generated .so
"""Compile a PYX file to a DLL and return the name of the generated .so
or .dll ."""
assert os.path.exists(filename), "Could not find %s" % os.path.abspath(filename)
......@@ -102,7 +102,7 @@ def pyx_to_dll(filename, ext=None, force_rebuild=0, build_in_temp=False, pyxbuil
dist.run_commands()
so_path = obj_build_ext.get_outputs()[0]
if obj_build_ext.inplace:
# Python distutils get_outputs()[ returns a wrong so_path
# Python distutils get_outputs()[ returns a wrong so_path
# when --inplace ; see http://bugs.python.org/issue5977
# workaround:
so_path = os.path.join(os.path.dirname(filename),
......@@ -139,7 +139,7 @@ def pyx_to_dll(filename, ext=None, force_rebuild=0, build_in_temp=False, pyxbuil
continue
break
else:
# used up all 100 slots
# used up all 100 slots
raise ImportError("reload count for %s reached maximum"%org_path)
_reloads[org_path]=(timestamp, so_path, count)
return so_path
......
......@@ -5,10 +5,10 @@ PYTHON -c "import a; import sys; sys.exit(a.compile_env_test())"
from distutils.core import setup
from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Distutils.old_build_ext import old_build_ext
setup(
cmdclass = {'build_ext': build_ext},
cmdclass = {'build_ext': old_build_ext},
ext_modules = [Extension(
"a", ["a.pyx"],
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