-
Notifications
You must be signed in to change notification settings - Fork 80
Description
setuptools version
72.1.0
Python version
3.10
OS
ubuntu 24.04
Additional environment information
Pixi env
Description
I've noticed that in newer versions of setuptools setup.py build_ext
no longer builds setuptools.Extension
s without any sources (a use case for that is to create a dummy extension that links against a shared library built using a boost.python with a different build-system, e.g. cmake):
demo_cxx = setuptools.Extension(
"demo._cxx", sources=[], libraries=["z"], language="c++"
)
I've created a simple example in https://github.com/twmr/setuptools_extension_demo
If I run python setup.py build
in this project, the following is output:
INFO:root:running build
INFO:root:running build_py
INFO:root:creating build
INFO:root:creating build/lib.linux-x86_64-cpython-310
INFO:root:creating build/lib.linux-x86_64-cpython-310/demo
INFO:root:copying demo/__init__.py -> build/lib.linux-x86_64-cpython-310/demo
INFO:root:running build_ext
python setup.py build_ext
only outputs:
INFO:root:running build_ext
If the log message in build_ext.py (distutils) was of type info then at least
INFO:root:skipping 'demo._cxx' extension (up-to-date)
would be output. This message is really helpful because it tells you why it wasn't build, even though the message is wrong in my case, because nothing was built at all.
I would expect to see the debug
log message by passing -vv
(or maybe just -v
) to build_ext
, but this doesn't work:
python setup.py build_ext -vv
outputs
INFO:root:running build_ext
The only way to trigger a build of the extension is to force the compilation of the extension.
using python setup.py build_ext -f
INFO:root:running build_ext
INFO:root:building 'demo._cxx' extension
INFO:root:g++ -pthread -B /home/thomas/pixi-main/oasis/demo/.pixi/envs/default/compiler_compat -shared -Wl,--allow-shlib-undefined -Wl,-rpath,/home/thomas/pixi-main/oasis/demo/.pixi/envs/default/lib -Wl,-rpath-link,/home/thomas/pixi-main/oasis/demo/.pixi/envs/default/lib -L/home/thomas/pixi-main/oasis/demo/.pixi/envs/default/lib -Wl,--allow-shlib-undefined -Wl,-rpath,/home/thomas/pixi-main/oasis/demo/.pixi/envs/default/lib -Wl,-rpath-link,/home/thomas/pixi-main/oasis/demo/.pixi/envs/default/lib -L/home/thomas/pixi-main/oasis/demo/.pixi/envs/default/lib -lz -o build/lib.linux-x86_64-cpython-310/demo/_cxx.cpython-310-x86_64-linux-gnu.so
Then there is also an issue with pip (I guess the root cause is in setuptools/distutils)
The build works fine, but the extension is not built in this case.
pip install .
Processing /home/thomas/pixi-main/oasis/demo
Preparing metadata (setup.py) ... done
Building wheels for collected packages: demo
Building wheel for demo (setup.py) ... done
Created wheel for demo: filename=demo-0.0.0-cp310-cp310-linux_x86_64.whl size=1062 sha256=49367f9e5050f46b43542037c265f5f715ffaffdcae583cd72b71bd62725634c
Stored in directory: /tmp/pip-ephem-wheel-cache-bzt2f2lc/wheels/3f/5a/f2/ecae9d14e02757feafed492662f1b09de2edde7b72ac0ba0bb
Successfully built demo
Installing collected packages: demo
Successfully installed demo-0.0.0
Expected behavior
I can verify that the extension was built with setuptools 62.6, but it is no longer built (unless -f
is specified).
The handling of debug log messages seems to be broken (-v
should output debug messages).
I would expect this log message https://github.com/pypa/setuptools/blob/04b3bb902e5853de4c5faf664847532602510e3e/setuptools/_distutils/command/build_ext.py#L530 to be output with level INFO
.
I don't think that it is good that setuptools bdist_wheel doesn't check that all extensions are there (regardless if they are rebuilt or not). This is the reason why pip install .
doesn't output an error, right?
How to Reproduce
see above
Output
see above