pip+virtualenv installation fix. closes #367

For unknown reasons (probably a mix between pip, setuptools and distutils invocation), our extension source are automatically replaced from pyx to c, and then, Cython is not doing its work.
So after invocation of the Extension.__init__, force again the source field.
This commit is contained in:
Mathieu Virbel 2012-01-19 16:24:44 +01:00
parent c7659d5f71
commit 1788700d2c
1 changed files with 20 additions and 17 deletions

View File

@ -140,9 +140,9 @@ if True:
pyxl.pop(0)
return '.'.join(pyxl)
OrigExtension = Extension
class CythonExtension(Extension):
def Extension(*args, **kwargs):
def __init__(self, *args, **kwargs):
# Small hack to only compile for x86_64 on OSX.
# Is there a better way to do this?
if platform == 'darwin':
@ -151,23 +151,26 @@ if True:
kwargs.get('extra_compile_args', [])
kwargs['extra_link_args'] = extra_args + \
kwargs.get('extra_link_args', [])
ext = OrigExtension(*args, **kwargs)
ext.pyrex_directives = {
Extension.__init__(self, *args, **kwargs)
self.pyrex_directives = {
'profile': 'USE_PROFILE' in environ,
'embedsignature': False}
return ext
# XXX with pip, setuptools is imported before distutils, and change
# our pyx to c, then, cythonize doesn't happen. So force again our
# sources
self.sources = args[1]
# simple extensions
for pyx in (x for x in pyx_files if not 'graphics' in x):
pxd = [x for x in pxd_files if not 'graphics' in x]
module_name = get_modulename_from_file(pyx)
ext_modules.append(Extension(module_name, [pyx] + pxd))
ext_modules.append(CythonExtension(module_name, [pyx] + pxd))
# opengl aware modules
for pyx in (x for x in pyx_files if 'graphics' in x):
pxd = [x for x in pxd_files if 'graphics' in x]
module_name = get_modulename_from_file(pyx)
ext_modules.append(Extension(
ext_modules.append(CythonExtension(
module_name, [pyx] + pxd,
libraries=libraries,
include_dirs=include_dirs,