-
Notifications
You must be signed in to change notification settings - Fork 69
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
Set Py_GIL_DISABLED=1
for free threaded Python on Windows
#310
Conversation
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.
LGTM
BTW I think we should release a new version that includes this PR ASAP. I think this issue have already been a block reason for the people who want to build free threading extension on windows |
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.
In case it helps: this change looks correct to me, and is the right (and probably the only reasonable) choice to make in my opinion. We made the same change in Meson (xref mesonbuild/meson#13338) and have tested it pretty heavily by now - it's working as advertised, while without the Py_GIL_DISABLED
define, users are getting hard to understand errors at build time.
So +1 for merging this.
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.
LGTM. It's unfortunate that we have to do that, but the fix looks good to me.
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 think the workaround is okay, but we should look into fixing the source of the issue.
The test failures seem unrelated. Unfortunately, they are also failing on |
When free threaded CPython is installed from the official Windows installer it doesn't have the macro `Py_GIL_DISABLED` properly set becuase its `pyconfig.h` file is shared across the co-installed default build. Define the macro when building free threaded Python extensions on Windows so that each individual C API extension doesn't have to work around this limitation. See pypa/setuptools#4662
407bd87
to
de1e624
Compare
The tests seem similar enough, I'll merge this and then see if I have time to fix the CI 🙃 |
I believe @zooba has already tried, and declared the approach in this PR as the solution to be able to build against the official CPython Windows installers until free-threaded becomes the default build - from https://discuss.python.org/t/windows-installer-freethreading-and-building-extension-modules/54391: "The multiple "It looks like you’re using setuptools. They can start detecting the variable and passing it themselves whenever they like." |
This specific issue is a symptom of Python not being designed to have paths shared between multiple builds. I think it makes sense to at least discuss in more depth how this could be avoided. |
Supporting the same set of headers for all platforms (or at minimum, all Windows architectures) and relying on preprocessor switches to choose the build options is a pretty standard way of doing this on Windows. I certainly wouldn't want to switch wholesale to a configure/make model for all Windows users just for the sake of a temporary flag. If there's a second feature that deserves this, we can consider it. |
Hey @FFY00! Are you going to merge this in pypa/setuptools as well? Having a released version of setuptools with this included would help a lot in unblocking CI for a lot of projects. |
When free threaded CPython is installed from the official Windows installer it doesn't have the macro
Py_GIL_DISABLED
properly set becuase itspyconfig.h
file is shared across the co-installed default build.Define the macro when building free threaded Python extensions on Windows so that each individual C API extension doesn't have to work around this limitation.
See pypa/setuptools#4662