Commit dc554166 authored by Stefan Behnel's avatar Stefan Behnel

repair build in Py3.2

parent f0418979
......@@ -167,11 +167,12 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
# XXX hack around setuptools quirk for '*.pyx' sources
extensions[-1].sources[0] = pyx_source_file
from Cython.Distutils import build_ext
if sys.version_info[:2] == (3, 2):
# Python 3.2: can only run Cython *after* running 2to3
build_ext = _defer_cython_import_in_py32(build_ext, source_root, profile)
elif profile:
build_ext = _defer_cython_import_in_py32(source_root, profile)
else:
from Cython.Distutils import build_ext
if profile:
from Cython.Compiler.Options import directive_defaults
directive_defaults['profile'] = True
sys.stderr.write("Enabled profiling for the Cython binary modules\n")
......@@ -181,9 +182,11 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
setup_args['ext_modules'] = extensions
def _defer_cython_import_in_py32(build_ext_orig, source_root, profile=False):
def _defer_cython_import_in_py32(source_root, profile=False):
# Python 3.2: can only run Cython *after* running 2to3
# => re-import Cython inside of build_ext
from distutils.command.build_ext import build_ext as build_ext_orig
class build_ext(build_ext_orig):
# we must keep the original modules alive to make sure
# their code keeps working when we remove them from
......@@ -205,16 +208,15 @@ def _defer_cython_import_in_py32(build_ext_orig, source_root, profile=False):
del sys.modules[module]
sys.path.insert(0, os.path.join(source_root, self.build_lib))
def finalize_options(self):
self.__reimport()
super(build_ext, self).finalize_options()
def build_extensions(self):
self.__reimport()
if profile:
from Cython.Compiler.Options import directive_defaults
directive_defaults['profile'] = True
print("Enabled profiling for the Cython binary modules")
from Cython.Build.Dependencies import cythonize
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules)
build_ext_orig.build_extensions(self)
return build_ext
......
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