[Distutils] [issue138] setuptools.extension incompatible w/ Cython (patch included)
JimC
setuptools at bugs.python.org
Tue Jun 12 23:08:13 CEST 2012
New submission from JimC <jim at carroll.com>:
We discovered a minor problem with setuptools.extension.py that prevents being able to incrementally build extenion modules when working with Cython (meaning, edits to source do NOT result in a call to the cython compiler).
A patch is attached to this ticket.
The problem is the extension.Extension() class has logic that alters the filename the sources[] list if Pyrex is not installed. The code has a simple boolean test if Pyrex is installed, and if not, it remaps the extension from ".pyx" -> ".c".
I believe the simple solution is to perform the same logic for Cython (to set a boolean if Cython is available, and to NOT remap the source extension if either Pyrex OR Cython is installed).
Example to demonstrate the problem:
setup('project',
...,
ext_modules = Extension('Prj', ['Prj/pr1.pyx']),
...,
cmdclass = {'build_ext': Cython.Distutils.build_ext},
...,
With a setup.py like this, the setuptools.extension.Extension class will re-write the sources[] list BEFORE the Cython.Distutils.build_ext module can get a shot at it.
The result is that subsequent edits of 'Prj/pr1.pyx' will cause build_ext to skip the cython compile step. The only work around to force a recompile is to delete the contents of the 'build/' folder.
See the suggested patch for our request for modification.
Thanks
----------
files: extension.patch
messages: 658
nosy: jim at carroll.com
priority: bug
status: unread
title: setuptools.extension incompatible w/ Cython (patch included)
Added file: http://bugs.python.org/setuptools/file80/extension.patch
_______________________________________________
Setuptools tracker <setuptools at bugs.python.org>
<http://bugs.python.org/setuptools/issue138>
_______________________________________________
-------------- next part --------------
--- \ORIGINAL\setuptools\extension.py Wed Sep 20 17:05:02 2006
+++ \REVISED\setuptools\extension.py Tue Jun 12 16:35:08 2012
@@ -1,15 +1,17 @@
from distutils.core import Extension as _Extension
from dist import _get_unpatched
_Extension = _get_unpatched(_Extension)
+have_pyrex = True
try:
from Pyrex.Distutils.build_ext import build_ext
except ImportError:
- have_pyrex = False
-else:
- have_pyrex = True
+ try:
+ from Cython.Distutils.build_ext import build_ext
+ except ImportError, exc:
+ have_pyrex = False
class Extension(_Extension):
"""Extension that uses '.c' files in place of '.pyx' files"""
More information about the Distutils-SIG
mailing list