Open burgholzer opened 1 month ago
Have you activated all verbosity options? SKBUILD_BUILD_VERBOSE=1
and SKBUILD_LOGGING_LEVEL=DEBUG
are the envvar versions. Comparing a working and failing build would be very interesting!
Using #include "../<stuff>"
is somewhat poor form, public headers should be included via <project/...>
(and including from a parent directory in the first place is poor structure). But I'm guessing since it's very specific, this likely isn't the problem. Though I'm slightly curious if we made a branch with absolute references here how the error message would change.
By the way, for free-threading on Windows, you have to define Py_GIL_DISABLED
on Windows. See https://gitlab.kitware.com/cmake/cmake/-/issues/26016.
Have you activated all verbosity options?
SKBUILD_BUILD_VERBOSE=1
andSKBUILD_LOGGING_LEVEL=DEBUG
are the envvar versions. Comparing a working and failing build would be very interesting!
I generated the following verbose logs:
uv pip install -v .
based on the nuget 3.13t version: https://github.com/cda-tum/mqt-qcec/actions/runs/10459830775/job/28964666813uv pip install -v "mqt.core @ git+https://github.com/cda-tum/mqt-core@shared-libs"
based on the nuget 3.13t version: https://github.com/cda-tum/mqt-qcec/actions/runs/10460243489/job/28966002637pip
instead of uv
(shows the successful build of mqt-core
by its own as well as the full install of mqt-qcec
): https://github.com/cda-tum/mqt-qcec/actions/runs/10461028878/job/28968492486What I do not quite get is that the two commands using uv
up there succeed on my local Windows VM, e.g.:
Note this is on a freshly cleaned uv
cache (to avoid any caching effects) in a fresh virtual environment. Unfortunately, uv
currently swallows all build backend output on successful builds. So I am not sure if there is much to make of the above.
Using
#include "../<stuff>"
is somewhat poor form, public headers should be included via<project/...>
(and including from a parent directory in the first place is poor structure). But I'm guessing since it's very specific, this likely isn't the problem. Though I'm slightly curious if we made a branch with absolute references here how the error message would change.
Note that these relative includes are coming from pybind11, e.g., https://github.com/pybind/pybind11/blob/a1d00916b26b187e583f3bce39cd59c3b0652c32/include/pybind11/detail/class.h#L12-L13
By the way, for free-threading on Windows, you have to define
Py_GIL_DISABLED
on Windows. See https://gitlab.kitware.com/cmake/cmake/-/issues/26016.
Thanks for pointing that out. Would https://github.com/cda-tum/mqt-core/pull/662/commits/f100a2e372c8d1c6e682328f4e9d3e3105307bf1 be an appropriate way of setting that? It seems to not really do anything if I am reading https://github.com/cda-tum/mqt-core/actions/runs/10459567906/job/28963824077?pr=662#step:8:6014 correctly. But I am probably missing something here.
appropriate way of setting that?
It's a C define, not a CMake define. It needs to be set on building any file that includes Python.h.
It's a C define, not a CMake define. It needs to be set on building any file that includes Python.h.
Gotcha, thanks! Adapted the code accordingly.
I also slightly extended the experimental workflow running 3.13t with some more combinations (Workflow | Log):
pip install -v "mqt.core @ git+https://github.com/cda-tum/mqt-core@shared-libs"
pip install -v . --no-deps
(--no-deps
solely because it otherwise tries to build numpy from source)build --wheel
build --wheel --installer=uv
I could be wrong, but it seems like the broken one has a //?/
prefix:
-- Disabling Python GIL
-- Found Python: \\?\C:\Users\runneradmin\AppData\Local\uv\cache\builds-v0\.tmp3yRqOT\Scripts\python.exe (found suitable version "3.13.0", minimum required is "3.8") found components: Interpreter Development.Module Development.SABIModule
...
-- Found pybind11: //?/C:/Users/runneradmin/AppData/Local/uv/cache/builds-v0/.tmp3yRqOT/Lib/site-packages/pybind11/include (found version "2.13.4")
While the working ones don't have this:
-- Found Python: C:\Users\runneradmin\AppData\Local\Temp\build-env-3doskkoe\Scripts\python.exe (found suitable version "3.13.0", minimum required is "3.8") found components: Interpreter Development.Module Development.SABIModule
...
-- Found pybind11: C:/Users/runneradmin/AppData/Local/Temp/build-env-3doskkoe/Lib/site-packages/pybind11/include (found version "2.13.4")
Assuming this is treated like a \\?\
prefix, this means the path is allowed to be longer than 256 chars, but it also disables path processing, which might cause the mix of /
and \
to trip up the compiler, perhaps? It also might trip up the usage of ..
, since ..
is valid in a path with a \\?\
prefix.
If all this is at least partially true, it might be that uv is adding this prefix in pyvenv.cfg
(possibly to support potentially long paths) and it's making it's way and something is either adding ..
or /
and making an invalid path. May be the wrong direction, but the fact this is showing up on the failing build is suspicious.
Edit: Just putting down where I am in debugging, as I'll be out for a bit. After I come back, I'll boot up a Windows box and play with these ideas a bit.
Assuming this is treated like a
\\?\
prefix, this means the path is allowed to be longer than 256 chars, but it also disables path processing, which might cause the mix of/
and\
to trip up the compiler, perhaps? It also might trip up the usage of..
, since..
is valid in a path with a\\?\
prefix.If all this is at least partially true, it might be that uv is adding this prefix in
pyvenv.cfg
(possibly to support potentially long paths) and it's making it's way and something is either adding..
or/
and making an invalid path. May be the wrong direction, but the fact this is showing up on the failing build is suspicious.
You could be onto something here. I can also confirm that a local (successful) cibuildhweel run on Windows with Python 3.11 contains the following in the build log
< -- Found Python: C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpSFszTP\Scripts\python.exe (found suitable version "3.11.9", minimum required is "3.8") found components: Interpreter Development.Module Development.SABIModule
...
< -- Pybind11 directory: C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpSFszTP\Lib\site-packages\pybind11\share\cmake\pybind11
< -- Python executable: C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpSFszTP\Scripts\python.exe
...
< -- Found pybind11: C:/Users/burgholzer/AppData/Local/uv/cache/builds-v0/.tmpSFszTP/Lib/site-packages/pybind11/include (found version "2.13.4")
While the (failing) 3.13t one contains
< -- Found Python: \\?\C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpqLWHdD\Scripts\python.exe (found suitable version "3.13.0", minimum required is "3.8") found components: Interpreter Development.Module Development.SABIModule
...
< -- Pybind11 directory: \\?\C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpqLWHdD\Lib\site-packages\pybind11\share\cmake\pybind11
< -- Python executable: \\?\C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpqLWHdD\Scripts\python.exe
...
< -- Found pybind11: //?/C:/Users/burgholzer/AppData/Local/uv/cache/builds-v0/.tmpqLWHdD/Lib/site-packages/pybind11/include (found version "2.13.4")
I don't quite understand what's so special about the free threading variant that would cause this though. Maybe @charliermarsh has any more insight in this, given how this seems to very much be related to uv
in some way.
Played around on a windows box; looks like //?/
still doesn't care about the type of slash, and \\?\
is equivalent, but it does break ..
handling (as it is supposed to). I'm guessing the compiler is just adding the the path direction to the include, and not resolving ..
itself, so that's why it breaks.
We're supposed to be stripping that //?
prefix when it's unambiguous (sometimes it's not possible, for complicated reasons that I don't fully understand related to Windows paths). It's not clear to me how it's appearing in one case but not the other...
Could you try this branch of pybind11 without the ..
's?
"pybind11 @ git+https://github.com/henryiii/pybind11@hernyiii/fix/upheader"
?
I wasn't able to easily get python3.13t
to get a \\?\
prefixed path in pyvenv.cfg trying it locally with the nuget package. I did run into some bugs with uv python list
along the way (I gave up trying to get 3.13rc1 with uv python
and used nuget, which is what cibuildwheel does).
We're supposed to be stripping that
//?
prefix when it's unambiguous (sometimes it's not possible, for complicated reasons that I don't fully understand related to Windows paths). It's not clear to me how it's appearing in one case but not the other...
Yeah. Really strange. It only seems to be happening on the free threaded variant of Python 3.13 and only when installing a git dependency (that needs to be built) as part of the build process.
Could you try this branch of pybind11 without the
..
's?
"pybind11 @ git+https://github.com/henryiii/pybind11@hernyiii/fix/upheader"
?
Sure: The respective workflow logs can be found here https://github.com/cda-tum/mqt-qcec/actions/runs/10478228069/job/29021100463?pr=432 (for the cibuildwheel run) and https://github.com/cda-tum/mqt-qcec/actions/runs/10478228069/job/29021098494?pr=432 (for the other experimental runs).
The cibuildwheel run succeeded 🥳
The other run still fails. The major difference between the two runs being that the cibuildwheel one is running with CMAKE_ARGS = "-T ClangCL"
, which means it is using clang as a compiler.
Without passing that flag, the default being used is MSVC as a compiler and that one still fails, although with a different error message that does not involve relative file paths:
C:\Users\runneradmin\AppData\Local\uv\git- v0\checkouts\8e9a633086c3b2cc\300693b3\include\mqt- core\python\pybind11.hpp(5,10): error C1083: Cannot open include file: 'pybind11/pybind11.h': No such file or directory [C:\Users\runneradmin\AppDa ta\Local\uv\git- v0\checkouts\8e9a633086c3b2cc\300693b3\build\Release\src\python\ir\ir.vcxpro j]
The file in question that is importing pybind11 is living here: https://github.com/cda-tum/mqt-core/blob/main/include/mqt-core/python/pybind11.hpp (nothing too fancy about that). The respective CMake target that includes it is here: https://github.com/cda-tum/mqt-core/blob/main/src/python/ir/CMakeLists.txt Although I don't quite think that is relevant.
I do see /external:I "//?/C:/Users/runneradmin/AppData/Local/uv/builds-v0/.tmpdZmHW4/Lib/site- packages/pybind11/include"
in the compiler invocation, so it seems like it should work unless MSVC doesn't support long paths.
That might be the case - it's possible (from things like https://developercommunity.visualstudio.com/t/allow-building-running-and-debugging-a-net-applica/351628) that MSVC may not support long paths.
Ok, I now have a bit of a better testing matrix set up (Workflow, CI Log).
All running uv 0.3.0
and the git dependency for pybind11 with the absolute paths.
C:\Users\runneradmin\AppData\Local\uv\git-v0\checkouts\8e9a633086c3b2cc\300693b3\include\mqt-core\python\pybind11.hpp(5,10): error C1083: Cannot open include file: 'pybind11/pybind11.h': No such file or directory [C:\Users\runneradmin\AppData\Local\uv\git-v0\checkouts\8e9a633086c3b2cc\300693b3\build\Release\src\python\ir\ir.vcxproj]
C:\Users\runneradmin\AppData\Local\uv\git-v0\checkouts\8e9a633086c3b2cc\300693b3\include\mqt-core\python\pybind11.hpp(5,10): error C1083: Cannot open include file: 'pybind11/pybind11.h': No such file or directory [C:\Users\runneradmin\AppData\Local\uv\git-v0\checkouts\8e9a633086c3b2cc\300693b3\build\Release\src\python\ir\ir.vcxproj]
CMake Error in CMakeLists.txt:
IMPORTED_IMPLIB not set for imported target "MQT::CoreDD" configuration
"Release".
C:\Users\runneradmin\AppData\Local\uv\git-
v0\checkouts\8e9a633086c3b2cc\300693b3\include\mqt-
core\python/pybind11.hpp(5): fatal error C1083: Cannot open include file:
'pybind11/pybind11.h': No such file or directory```
That might be the case - it's possible (from things like https://developercommunity.visualstudio.com/t/allow-building-running-and-debugging-a-net-applica/351628) that MSVC may not support long paths.
That might explain all the MSVC failures. It still doesn't quite explain the uv - ClangCL
failure. Quick googling around also points towards this being an issue with certain paths not being found.
I'm going to go ahead and make a scikit-build-core release with a couple of other fixes, don't think this is a scikit-build-core issue (and can always fix and release if it does turn out to be). It's most likely a mix of a uv issue (not simplifying this when I think it could), and MSVC not understanding these paths.
I'd really be interested to see the contents of the pyvenv.cfg
files for a uv environment in this setting!
It's most likely a mix of a uv issue (not simplifying this when I think it could), and MSVC not understanding these paths.
Agreed. Although it's still kind of puzzling to me that this is only happening on 3.13t and nowhere else.
@charliermarsh should I file this as an uv
issue to investigate this further?
I'd really be interested to see the contents of the
pyvenv.cfg
files for a uv environment in this setting!
Where would that file be located in the build? Maybe I could try to extract it somehow. Unfortunately, I probably won't have access to my windows machine for the next two weeks.
Anyway. Once the pybind11 fix is merged and released, there at least is a way forward to build our projects on 3.13t 🚀
Please feel free to file a uv issue!
It's in the base of the virtual environments. cat $VIRTUAL_ENV/pyvenv.cfg
basically. python -c 'import sys; from pathlib import Path; print(Path(sys.prefix).joinpath("pyvenv.cfg").read_text())'
would print it in a cross-platform way, I believe.
Anyway. Once the pybind11 fix is merged and released, there at least is a way forward to build our projects on 3.13t 🚀
pybind11 2.13.5 is out!
Anyway. Once the pybind11 fix is merged and released, there at least is a way forward to build our projects on 3.13t 🚀
pybind11 2.13.5 is out!
Nice! Thanks for the quick release.
I'll try to get to the last two comments in this thread in the next couple of days (always a bit hard to plan on vacation).
Please feel free to file a uv issue!
x-ref: filed https://github.com/astral-sh/uv/issues/6948
It's in the base of the virtual environments.
cat $VIRTUAL_ENV/pyvenv.cfg
basically.python -c 'import sys; from pathlib import Path; print(Path(sys.prefix).joinpath("pyvenv.cfg").read_text())'
would print it in a cross-platform way, I believe.
Thanks for the tip. Ran that locally on my Windows VM to get the pyenv.cfg
of the venv that the mqt-core
build time dependency is being built in and it prints
home = C:\Users\burgholzer\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\python-freethreaded.3.13.0-rc1\tools
implementation = CPython
uv = 0.4.2
version_info = 3.13.0rc1
include-system-site-packages = false
relocatable = false
The Python_EXECUTABLE
to print this was \\?\C:\Users\burgholzer\AppData\Local\uv\cache\builds-v0\.tmpRmcSyJ\Scripts\python.exe
For the venv that runs the isolated build of mqt-qcec
the pyenv.cfg
looks like this
home = C:\Users\burgholzer\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\python-freethreaded.3.13.0-rc1\tools
include-system-site-packages = false
version = 3.13.0
executable = C:\Users\burgholzer\AppData\Local\Temp\cibw-run-os7xk_t1\cp313t-win_amd64\build\venv\Scripts\python.exe
command = C:\Users\burgholzer\AppData\Local\Temp\cibw-run-os7xk_t1\cp313t-win_amd64\build\venv\Scripts\python.exe -m venv --without-pip --without-scm-ignore-files C:\Users\burgholzer\AppData\Local\Temp\build-env-d4_sgdys
With Python_EXECUTABLE
being C:\Users\burgholzer\AppData\Local\Temp\build-env-d4_sgdys\Scripts\python.exe
Description
Hi 👋🏼
First things first: I am not 100% sure what I am about to describe is a cibuildwheel issue, but it was the only scenario under which I could reproduce the issue. Feel free to transfer this issue to its appropriate place or point me there.
Context
We are currently working on improving one of our libraries (https://github.com/cda-tum/mqt-qcec, built in C++, exposed to Python via pybind11, using scikit-build-core as a build backend) to get some of its build time dependencies (including C++ shared libraries) via another one of our packages (https://github.com/cda-tum/mqt-core; same setup as the other tool) kind of similar to how
pybind11
is distributed as a Python package and can then be found viafind_package
in CMake.The respective PRs in question are: https://github.com/cda-tum/mqt-qcec/pull/432 and https://github.com/cda-tum/mqt-core/pull/662
For the development, we added
mqt.core
as a git dependency to themqt.qcec
package configuration (see here):Almost everything works smoothly with this setup and nearly all the CI workflows are green, except one:
Problem
Running
cibuildwheel
on Windows to build Python 3.13 free-threading wheels. A corresponding failing CI log can be found here. Interestingly, it fails to properly build themqt.core
git dependency from the build requirements. The errors from the CI log all boil down to something similar asindicating that something is messed up with the pybind11 include directories.
Note that the same job succeeds on Ubuntu (also with emulation based on QEMU), macOS (x86 and arm64), as well as Windows (despite the 3.13t job), as can be seen from all the build logs here.
The cibuildwheel configuration of the
mqt.qcec
project is here.What I tried to narrow down the problem
This is only happening on Windows and for Python 3.13t
We are using the
build[uv]
build frontend and the errors are isolated to that particular choice. More precisely, they are limited to the use ofuv
as the installer. Both, choosing justbuild
as well as the regularpip
frontend in the cibuildwheel config makes the job succeed.Installing Python 3.13t from the official website, creating a new virtual environment with
uv
using that Python version and runninguv pip install .
in a fresh clone of themqt-qcec
branch also succeeds without issuesRunning
python -m build --wheel --installer=uv
in a newly createduv
Python 3.13t venv also succeeds.This was tested with
uv 0.2.37
, but also failed with a couple versions before that.Running cibuildwheel on the
mqt.core
sub-project runs successfully, even on windows with Python 3.13t. See the corresponding CI log.Running
pipx run cibuildwheel --only cp313t-win_amd64
consistently fails with the above errors.Steps to reproduce the problem
On a Windows machine with pipx installed:
The issue is probably right at the intersection of
cibuildwheel
,scikit-build-core
,pybind11
,uv
and some Python 3.13 free-threading change. However, even after longer sessions of debugging, I couldn't really make sense of it.Build log
https://github.com/cda-tum/mqt-qcec/actions/runs/10392166048/job/28783894623
CI config
https://github.com/cda-tum/mqt-workflows/blob/a9a471582a6aefc2a71ab50772707829edb2abc3/.github/workflows/reusable-python-packaging.yml#L67-L118