File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 2323)
2424from ..extension import Extension
2525from ..sysconfig import customize_compiler , get_config_h_filename , get_python_version
26- from ..util import get_platform , is_mingw
26+ from ..util import get_platform , is_mingw , is_freethreaded
2727
2828# An extension name is just a dot-separated list of Python NAMEs (ie.
2929# the same as a fully-qualified module name).
@@ -333,6 +333,12 @@ def run(self): # noqa: C901
333333 if os .name == 'nt' and self .plat_name != get_platform ():
334334 self .compiler .initialize (self .plat_name )
335335
336+ # The official Windows free threaded Python installer doesn't set
337+ # Py_GIL_DISABLED because its pyconfig.h is shared with the
338+ # default build, so define it here (pypa/setuptools#4662).
339+ if os .name == 'nt' and is_freethreaded ():
340+ self .compiler .define_macro ('Py_GIL_DISABLED' , '1' )
341+
336342 # And make sure that any compile/link-related options (which might
337343 # come from the command-line or from the setup script) are set in
338344 # that CCompiler object -- that way, they automatically apply to
Original file line number Diff line number Diff line change @@ -503,3 +503,7 @@ def is_mingw():
503503 get_platform() starts with 'mingw'.
504504 """
505505 return sys .platform == 'win32' and get_platform ().startswith ('mingw' )
506+
507+ def is_freethreaded ():
508+ """Return True if the Python interpreter is built with free threading support."""
509+ return bool (sysconfig .get_config_var ('Py_GIL_DISABLED' ))
You can’t perform that action at this time.
0 commit comments