New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake cannot find Python headers for pybind11 project #639
Comments
Maybe @henryiii could tell more, but I suggest checking CMake version installed inside docker. It may be too old. Also, you may try to install a modern version of CMake from pip. https://pypi.org/project/cmake/ |
@Czaki thanks, great suggestion! I was hopeful because in the past older Ubuntu version needed a more recent CMake installed via pip. So I added the command to So my current guess is that the Python headers are in a non-standard location in the images, which would not be too surprising. What I find strange is that @henryiii 's pybind11 cmake example does not require any additional path additions in his wheels.yml file. The CMake file is different from ours in that it uses a |
if Sometimes user does not have administration rights and needs to install it in userspace. The localization of Python interpreter used by cibuildwheel you could check here https://github.com/joerick/cibuildwheel/blob/master/cibuildwheel/resources/build-platforms.toml |
@Czaki I agree with everything you said. I expect the CMake find_package helper to use the interpreter (because you have to pass in the path to the interpreter for it to work), but it's not clear from the CMake documentation. I guess it's probably that something else. Thanks for the link to that file specifying the paths. I am now printing the python interpreter that is being used when building the wheel, and it's Also, is there an environment variable set by cibuildwheel which specifies the python root directory being uses that I can maybe send as a hint to my CMake build file? |
I do not think that this is a proper interpreter for build purpose. I think that you could set such a variable inside your |
Ok, thanks. I'm obtaining it and passing it to CMake in the same way as @henryiii's CMake example (using |
@lanctot Can you try without requiring
I believe the manylinux images don't provide the libraries by default, but just the headers. I've ran into this before, but I'm not sure I can find the relevant issue again :-/ |
OK, see here: https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode And this: pybind/pybind11#2689 (That was easier than expected! |
Ok, very different output based on that change (but interesting.. but that doesn't work locally for some reason):
It is now failing in a different place (and does not seem related to cibuildwheel), so I will consider this fixed.. thanks @YannickJadoul ! BTW is that correct for the executable and include dirs combination? I'm surprised that the executable and include dirs don't share a common path prefix (maybe due to some symbolic linking under the hood?) |
I think that's pretty normal for virtual environments, the headers may come from the original location, and the executable will come from the venv dir. |
Huh, so this is a path on macOS, and not in a manylinux Docker image? Shouldn't your macOS environment also have the |
Oh I apologize, I am testing both ubuntu-20.04 (via manylinux2014) and macOS-10.15 concurrently and this last time the MacOS build failed first and cancelled the Ubuntu run. I will try just the Ubuntu run later tonight to see what happens and report back. Thanks so much for the help! |
Aha, OK, then all is fine, if the first issue was |
Hi @YannickJadoul, just confirming that your suggestion worked and I was able to progress further on the ubuntu-20.04 (manylinux2014). The build is now failing with different C++ compilation errors (both MacOS and Ubuntu), and they seem to be related to our code not being friendly to older/different compilers.. so I just have to go through and fix each instance. Thanks again! |
@lanctot Great to hear! Thanks for the small update :-) |
@YannickJadoul Is there any other fix than removing |
I believe |
Hi all,
Wonderful project, thank you so much for providing this to the community! And thanks to everyone who responded on my thread yesterday; I'm now using g++ for Linux and clang++ on MacOS.
I seem to be running into a problem where my CMake project cannot find the Python development headers in the docker images, but I have never had this issue locally nor in our GitHub actions CI.
Specifically, I see:
when running CMake and then compilation errors that Python.h is not found.
My wheels file is here: https://github.com/lanctot/open_spiel/blob/master/.github/workflows/wheels.yml
The line we use to find the headers in CMake is here: https://github.com/lanctot/open_spiel/blob/6c096e4913e8ccc2126d6e0bb7b69a9ed552c91f/open_spiel/python/CMakeLists.txt#L1
Tagging @henryiii because I based my wheels file on his CMake example in the pybind11 repos.
The text was updated successfully, but these errors were encountered: