gudhi-devel
gudhi-devel copied to clipboard
[cython] cython generates .cpp files in the source tree instead of the build tree
Cython generates .cpp files from .pyx files, and writes them in the source tree instead of the build tree. Ideally, it would write them in the build tree instead. The reason I noticed is that the following scenario happened several times to me: I build the python plugin directly from the git sources, then I modify the sources (possibly switch branch), create a user_version, build the python plugin from that user_version, and get confused because my modifications were not taken into account. Indeed, the user_version includes the stale .cpp that were lying around in src/python/gudhi, probably with a modification time just as recent as the .pyx so the build doesn't feel the need to regenerate them. It looks like I should be more consistent, either always build a user_version, or never. Still, it may not be too hard to make the user_version generation explicitly exclude src/python/gudhi/*.cpp from the list of files to copy.
In setup.py, I tried cython_c_in_temp
option:
# Create ext_modules list from module list
ext_modules = []
for module in cython_modules:
module = Extension(
'gudhi.' + module,
sources = [source_dir + module + '.pyx',],
language = 'c++',
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
libraries=libraries,
library_dirs=library_dirs,
include_dirs=include_dirs,
runtime_library_dirs=runtime_library_dirs,
cython_directives = {'language_level': str(sys.version_info[0])},)
module.cython_c_in_temp = True
ext_modules.append(module)
I also tried to call python setup.py build_ext
with option --build-temp
, but nothing to do...
Thanks to Vincent's PR, those outdated .cpp files are not copied in user_version anymore, which removes this trap. Keeping open because it isn't clean to generate files in the source directory, but this is less urgent now.
I think we can close this issue thanks to https://github.com/cython/cython/issues/4312