-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix Pybind11Extension on Mingw64 #2921
Conversation
* Pybind11Extension add the "/EHsc /bigobj /std:c++14" flags on Windows. This is good for Visual C++ but not for Mingw. * According https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python2/0410-MINGW-build-extensions-with-GCC.patch sysconfig.get_platform() is the way to check for a Mingw64
Great to see fixes for MinGW! Would you have suggestions for how to run minGW in GHA? I'd like to test for it, too, but don't know anything about using MinGW. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it's fine to merge this change even if we don't have a MINGW GitHub Action at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm perfectly fine to merge this change as is, but I don't find someone with MinGW knowledge that often, so I'm hoping I can get some advice and/or maybe actually finally add a MinGW run to the tests. :) (And I thought I already approved, but I guess not)
Thanks @jeromerobert and @henryiii ! I'll merge this now. If you can help us with GHA that'll be great, but optional. |
Just logging my thinking here about GHA:
|
These things pop up every so often, especially the the example repos. It's very much worth having if we can do it easily. I'm guessing that it's possible and pretty easy if you know how to set it up. We promise MinGW support in the readme, so it should be tested (I think now it is the only one promised that is not tested, actually). I'm hoping someone who cares about MinGW will help set it up one day. |
@henryiii Using https://github.com/msys2/setup-msys2 it should be easy enough to add a test for Mingw64. What existing PyBind11 Github Actions job could we take inspiration from? |
Well, any of the checks, maybe this one is close: pybind11/.github/workflows/ci.yml Lines 751 to 795 in f676782
We don't really test the one thing that you fixed here, but just that pybind11 compiles correctly; IIRC the python extensions are tested only in pybind/python_example, https://github.com/pybind/python_example/blob/master/.github/workflows. If we had a test in pybind11, it could be duplicated there (it uses pip instead of CMake). I'd only add 1-2 checks, say 64 bit and 32 bit for some version of Python. |
FYI, this doesn't seem to work (like all untested code 🤣 ). I believe sysconfig only tells you what Python was built with, not what you are targeting. That requires a custom build_ext (which I believe I literally wrote in a comment somewhere in the docs). A fix will need to patch the build_ext command and change these arguments if mingw64 is being used. |
Description
Pybind11Extension
add the/EHsc /bigobj /std:c++14
flags on Windows.This is good for Visual C++ but not for Mingw.
https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-python2/0410-MINGW-build-extensions-with-GCC.patch
sysconfig.get_platform() is the way to check for a Mingw64
Suggested changelog entry:
Fix the default ``Pybind11Extension`` compilation flags with a Mingw64 python