diegoferigo / cmake-build-extension

Setuptools extension to build and package CMake projects
https://pypi.org/project/cmake-build-extension/
MIT License
67 stars 16 forks source link

Using cmake extension modules alongside other extension modules #33

Open Xiretza opened 2 years ago

Xiretza commented 2 years ago

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?

diegoferigo commented 2 years ago

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?

Xiretza commented 2 years ago

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.

diegoferigo commented 2 years ago

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

Xiretza commented 2 years ago

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.

kdewald commented 2 years ago

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