-
Notifications
You must be signed in to change notification settings - Fork 804
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
build.rs fails to parse hand-written pyconfig.h headers installed by python for windows (MSVC-compiled) #1337
Comments
Hi @ravenexp thanks for the report. Is there a (See |
No, there isn't. It could be that the ArchLinux package author has chosen not to install it, though. BTW, what kind of configuration data pyo3 needs to build an extension module for Windows? Perhaps it is possible to provide the same information via environment variables and avoid looking at the cross python installation files at all (except for the python DLL import library)? |
Hi @ravenexp, thank you for reporting.
See https://github.com/PyO3/pyo3/blob/v0.13.0/build.rs#L198. |
Thank you for your prompt responses. I've stumbled upon this function: Line 507 in 26ca1f5
and "PC\pyconfig.h" is exactly the header I've quoted before. As I've said, the arch mingw python package installs MSVC headers. But is it really feasible to build a working python 3.5+ for windows without wide Unicode, dynamic linking and threading support? |
I did some research on the impact of the build config variables on the extension module ABI. The ./configure flag --with-wide-unicode has been removed in Python 3.3.
What's left is |
Thanks, I've opened #1350 based on that research! I think it might even be reasonable to remove the header parsing entirely, though that's a breaking change so will wait until 0.14. |
I have retried building my extension module with pyo3 git master after #1350 was merged. When PYO3_CROSS_INCLUDE_DIR is not set, I'm greeted with the following new error message:
When I set the PYO3_CROSS_INCLUDE_DIR to point to the windows python headers, I get the same old:
but, when I set either PYO3_CROSS_PYTHON_VERSION, or an abi3-py3* feature everything works as expected. My cross-compilation problem is essentially solved by #1350, but the reported windows pyconfig.h parsing bug is still there. |
Thanks for following up @ravenexp . I agree now I think about it that the error messages are still not great. I am aware the original INCLUDE_DIR issue still remains. I think that as the other options now work well, I'd be keen to remove the header parsing entirely in pyO3 0.14. This'll "fix" the bug and I'll improve the help messages at the same time. |
The config header parsing code was supposed to be only invoked when cross-compiling for Windows, but in reality it fails to correctly parse the config header files shipped with the upstream Python for Windows. Given that there are now better options for reliable cross-compiling for Windows such as `PYO3_CROSS_PYTHON_VERSION` or the `abi3-py3*` features, it should be OK to remove this config for v0.14. Update the cross-compilation instructions section of the user guide. Fixes PyO3#1337
🐛 Bug Reports
When trying to cross-compile a python extension for windows on linux using the mingw target I get the following error:
pyconfig.h from python 3.9.1 for windows (built with the MSVC compiler), which I have installed, contains the following lines:
When I manually add the line
to pyconfig.h the error disappears.
I believe the following code fails to parse C headers with white space between # and define,
as well as with the comments:
https://github.com/PyO3/pyo3/blob/master/build.rs#L224
The C header parsing code should somehow be restricted to generated pyconfig.h headers only.
Manually written pyconfig.h from python for MSVC does not work.
🌍 Environment
Arch Linux
python 3.9.1
mingw-w64-python39-bin 3.9.1 <- this is the MSVC-compiled python, not the MinGW-compiled python
rustc 1.48.0
pyo3 0.13.0
The text was updated successfully, but these errors were encountered: