cmake-build-extension
cmake-build-extension copied to clipboard
Using cmake extension modules alongside other extension modules
Unless I'm misinterpreting something, using BuildExtension
as cmdclass['build_ext']
in setup.py
makes any non-cmake extension modules completely ineffective, because BuildExtension.run()
simply ignores them: https://github.com/diegoferigo/cmake-build-extension/blob/2c3d822e40fe3fd2d769ad09dba367e6617dcc82/src/cmake_build_extension/build_extension.py#L82
Is my understanding correct? How would I use this project if I also have e.g. cython
extension modules?
Hi @Xiretza, thanks for raising this point. I'm not really sure to be honest, I'm not expert in setuptools hooks and I naively assumed that each build extension should process only its own stuff. I imagine that also other build extensions implement their own BuildExtension.run
method, and I assume that they also filter their instance but I might be wrong.
What's the behavior you're experiencing? Are you sure that the line you linked prevents the execution of other build extensions? Can you check on your example by adding some print statements in all run
methods of the extensions you're using?
This project overrides the global build_ext
:
https://github.com/diegoferigo/cmake-build-extension/blob/2c3d822e40fe3fd2d769ad09dba367e6617dcc82/example/setup.py#L106
As far as I can tell there can only be one build_ext
, and if it filters out all modules it isn't specifically designed for, that's just not gonna work.
Ok now I see what you mean, do you have any suggestion on how to work around this limitation?
Not really. BuildExtension.run()
should probably call super().run()
at some point, but that will of course try to build and install the CMakeExtension
s as well.
@diegoferigo you could in theory skip most of the preprocessing that is currently being done in the run
function and check instance types inside build_extension
and forwarding to the correct build_ext
object.