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 23
23
)
24
24
from ..extension import Extension
25
25
from ..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
27
27
28
28
# An extension name is just a dot-separated list of Python NAMEs (ie.
29
29
# the same as a fully-qualified module name).
@@ -333,6 +333,12 @@ def run(self): # noqa: C901
333
333
if os .name == 'nt' and self .plat_name != get_platform ():
334
334
self .compiler .initialize (self .plat_name )
335
335
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
+
336
342
# And make sure that any compile/link-related options (which might
337
343
# come from the command-line or from the setup script) are set in
338
344
# 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():
503
503
get_platform() starts with 'mingw'.
504
504
"""
505
505
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