Commit dc554166 authored by Stefan Behnel's avatar Stefan Behnel

repair build in Py3.2

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