cmake-build-extension icon indicating copy to clipboard operation
cmake-build-extension copied to clipboard

Using cmake extension modules alongside other extension modules

Open Xiretza opened this issue 2 years ago • 5 comments

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?

Xiretza avatar Jun 11 '22 13:06 Xiretza

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?

diegoferigo avatar Jun 14 '22 21:06 diegoferigo

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.

Xiretza avatar Jun 15 '22 13:06 Xiretza

Ok now I see what you mean, do you have any suggestion on how to work around this limitation?

diegoferigo avatar Jun 15 '22 13:06 diegoferigo

Not really. BuildExtension.run() should probably call super().run() at some point, but that will of course try to build and install the CMakeExtensions as well.

Xiretza avatar Jun 15 '22 13:06 Xiretza

@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.

kdewald avatar Sep 03 '22 19:09 kdewald