From 1788700d2c395e29ca2218f0373878470e3278e5 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 19 Jan 2012 16:24:44 +0100 Subject: [PATCH] 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. --- setup.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index cfccf64ac..25ebc7ebd 100644 --- a/setup.py +++ b/setup.py @@ -140,34 +140,37 @@ if True: pyxl.pop(0) return '.'.join(pyxl) - OrigExtension = Extension + class CythonExtension(Extension): - def Extension(*args, **kwargs): - # Small hack to only compile for x86_64 on OSX. - # Is there a better way to do this? - if platform == 'darwin': - extra_args = ['-arch', 'x86_64'] - kwargs['extra_compile_args'] = extra_args + \ - kwargs.get('extra_compile_args', []) - kwargs['extra_link_args'] = extra_args + \ - kwargs.get('extra_link_args', []) - ext = OrigExtension(*args, **kwargs) - ext.pyrex_directives = { - 'profile': 'USE_PROFILE' in environ, - 'embedsignature': False} - return ext + 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': + extra_args = ['-arch', 'x86_64'] + kwargs['extra_compile_args'] = extra_args + \ + kwargs.get('extra_compile_args', []) + kwargs['extra_link_args'] = extra_args + \ + kwargs.get('extra_link_args', []) + Extension.__init__(self, *args, **kwargs) + self.pyrex_directives = { + 'profile': 'USE_PROFILE' in environ, + 'embedsignature': False} + # 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,