Skip to content

Commit aa326a6

Browse files
zoobaaisk
authored andcommitted
pythongh-111650: Ensure pyconfig.h includes Py_GIL_DISABLED on Windows (pythonGH-112778)
1 parent 6ad31bb commit aa326a6

25 files changed

+112
-44
lines changed

.github/workflows/reusable-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
- name: Build CPython
19-
run: .\PCbuild\build.bat -e -d -p Win32 ${{ inputs.free-threaded && '--disable-gil' || '' }}
19+
run: .\PCbuild\build.bat -e -d -v -p Win32 ${{ inputs.free-threaded && '--disable-gil' || '' }}
2020
- name: Display build info
2121
run: .\python.bat -m test.pythoninfo
2222
- name: Tests
@@ -33,7 +33,7 @@ jobs:
3333
- name: Register MSVC problem matcher
3434
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
3535
- name: Build CPython
36-
run: .\PCbuild\build.bat -e -d -p x64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
36+
run: .\PCbuild\build.bat -e -d -v -p x64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
3737
- name: Display build info
3838
run: .\python.bat -m test.pythoninfo
3939
- name: Tests
@@ -50,4 +50,4 @@ jobs:
5050
- name: Register MSVC problem matcher
5151
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
5252
- name: Build CPython
53-
run: .\PCbuild\build.bat -e -d -p arm64 ${{ inputs.free-threaded && '--disable-gil' || '' }}
53+
run: .\PCbuild\build.bat -e -d -v -p arm64 ${{ inputs.free-threaded && '--disable-gil' || '' }}

Lib/sysconfig/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,16 @@ def get_config_h_filename():
404404
"""Return the path of pyconfig.h."""
405405
if _PYTHON_BUILD:
406406
if os.name == "nt":
407-
inc_dir = os.path.join(_PROJECT_BASE, "PC")
407+
# This ought to be as simple as dirname(sys._base_executable), but
408+
# if a venv uses symlinks to a build in the source tree, then this
409+
# fails. So instead we guess the subdirectory name from sys.winver
410+
if sys.winver.endswith('-32'):
411+
arch = 'win32'
412+
elif sys.winver.endswith('-arm64'):
413+
arch = 'arm64'
414+
else:
415+
arch = 'amd64'
416+
inc_dir = os.path.join(_PROJECT_BASE, 'PCbuild', arch)
408417
else:
409418
inc_dir = _PROJECT_BASE
410419
else:

Lib/test/test_sysconfig.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,15 @@ def test_srcdir(self):
472472
# should be a full source checkout.
473473
Python_h = os.path.join(srcdir, 'Include', 'Python.h')
474474
self.assertTrue(os.path.exists(Python_h), Python_h)
475-
# <srcdir>/PC/pyconfig.h always exists even if unused on POSIX.
476-
pyconfig_h = os.path.join(srcdir, 'PC', 'pyconfig.h')
475+
# <srcdir>/PC/pyconfig.h.in always exists even if unused
476+
pyconfig_h = os.path.join(srcdir, 'PC', 'pyconfig.h.in')
477477
self.assertTrue(os.path.exists(pyconfig_h), pyconfig_h)
478478
pyconfig_h_in = os.path.join(srcdir, 'pyconfig.h.in')
479479
self.assertTrue(os.path.exists(pyconfig_h_in), pyconfig_h_in)
480+
if os.name == 'nt':
481+
# <executable dir>/pyconfig.h exists on Windows in a build tree
482+
pyconfig_h = os.path.join(sys.executable, '..', 'pyconfig.h')
483+
self.assertTrue(os.path.exists(pyconfig_h), pyconfig_h)
480484
elif os.name == 'posix':
481485
makefile_dir = os.path.dirname(sysconfig.get_makefile_filename())
482486
# Issue #19340: srcdir has been realpath'ed already

Lib/test/test_venv.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@
4646
def check_output(cmd, encoding=None):
4747
p = subprocess.Popen(cmd,
4848
stdout=subprocess.PIPE,
49-
stderr=subprocess.PIPE,
50-
encoding=encoding)
49+
stderr=subprocess.PIPE)
5150
out, err = p.communicate()
5251
if p.returncode:
5352
if verbose and err:
54-
print(err.decode('utf-8', 'backslashreplace'))
53+
print(err.decode(encoding or 'utf-8', 'backslashreplace'))
5554
raise subprocess.CalledProcessError(
5655
p.returncode, cmd, out, err)
56+
if encoding:
57+
return (
58+
out.decode(encoding, 'backslashreplace'),
59+
err.decode(encoding, 'backslashreplace'),
60+
)
5761
return out, err
5862

5963
class BaseTest(unittest.TestCase):
@@ -281,8 +285,8 @@ def test_sysconfig(self):
281285
('get_config_h_filename()', sysconfig.get_config_h_filename())):
282286
with self.subTest(call):
283287
cmd[2] = 'import sysconfig; print(sysconfig.%s)' % call
284-
out, err = check_output(cmd)
285-
self.assertEqual(out.strip(), expected.encode(), err)
288+
out, err = check_output(cmd, encoding='utf-8')
289+
self.assertEqual(out.strip(), expected, err)
286290

287291
@requireVenvCreate
288292
@unittest.skipUnless(can_symlink(), 'Needs symlinks')
@@ -303,8 +307,8 @@ def test_sysconfig_symlinks(self):
303307
('get_config_h_filename()', sysconfig.get_config_h_filename())):
304308
with self.subTest(call):
305309
cmd[2] = 'import sysconfig; print(sysconfig.%s)' % call
306-
out, err = check_output(cmd)
307-
self.assertEqual(out.strip(), expected.encode(), err)
310+
out, err = check_output(cmd, encoding='utf-8')
311+
self.assertEqual(out.strip(), expected, err)
308312

309313
if sys.platform == 'win32':
310314
ENV_SUBDIRS = (
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ensures the ``Py_GIL_DISABLED`` preprocessor variable is defined in
2+
:file:`pyconfig.h` so that extension modules written in C are able to use
3+
it.

Modules/_ctypes/_ctypes_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#ifndef _MSC_VER
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#endif
42

53
#ifndef Py_GIL_DISABLED
64
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

Modules/_scproxy.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* using the SystemConfiguration framework.
44
*/
55

6-
#ifndef _MSC_VER
76
#include "pyconfig.h" // Py_GIL_DISABLED
8-
#endif
97

108
#ifndef Py_GIL_DISABLED
119
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

Modules/_stat.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
*
1212
*/
1313

14-
#ifndef _MSC_VER
1514
#include "pyconfig.h" // Py_GIL_DISABLED
16-
#endif
1715

1816
#ifndef Py_GIL_DISABLED
1917
// Need limited C API version 3.13 for PyModule_Add() on Windows

Modules/_testcapi/heaptype_relative.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#ifndef _MSC_VER
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#endif
42

53
#ifndef Py_GIL_DISABLED
64
#define Py_LIMITED_API 0x030c0000 // 3.12

Modules/_testcapi/vectorcall_limited.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* Test Vectorcall in the limited API */
22

3-
#ifndef _MSC_VER
43
#include "pyconfig.h" // Py_GIL_DISABLED
5-
#endif
64

75
#ifndef Py_GIL_DISABLED
86
#define Py_LIMITED_API 0x030c0000 // 3.12

Modules/_testclinic_limited.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
#undef Py_BUILD_CORE_MODULE
55
#undef Py_BUILD_CORE_BUILTIN
66

7-
#ifndef _MSC_VER
87
#include "pyconfig.h" // Py_GIL_DISABLED
9-
#endif
108

119
#ifndef Py_GIL_DISABLED
1210
// For now, only limited C API 3.13 is supported

Modules/_testimportmultiple.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
* foo, bar), only the first one is called the same as the compiled file.
55
*/
66

7-
#ifndef _MSC_VER
87
#include "pyconfig.h" // Py_GIL_DISABLED
9-
#endif
108

119
#ifndef Py_GIL_DISABLED
1210
#define Py_LIMITED_API 0x03020000

Modules/_uuidmodule.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
* DCE compatible Universally Unique Identifier library.
44
*/
55

6-
#ifndef _MSC_VER
76
#include "pyconfig.h" // Py_GIL_DISABLED
8-
#endif
97

108
#ifndef Py_GIL_DISABLED
119
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

Modules/errnomodule.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* Errno module */
22

3-
#ifndef _MSC_VER
43
#include "pyconfig.h" // Py_GIL_DISABLED
5-
#endif
64

75
#ifndef Py_GIL_DISABLED
86
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

Modules/resource.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#ifndef _MSC_VER
21
#include "pyconfig.h" // Py_GIL_DISABLED
3-
#endif
42

53
#ifndef Py_GIL_DISABLED
64
// Need limited C API version 3.13 for PySys_Audit()

Modules/xxlimited.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@
6262
pass
6363
*/
6464

65-
#ifndef _MSC_VER
6665
#include "pyconfig.h" // Py_GIL_DISABLED
67-
#endif
6866

6967
#ifndef Py_GIL_DISABLED
7068
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

Modules/xxlimited_35.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
* See the xxlimited module for an extension module template.
66
*/
77

8-
#ifndef _MSC_VER
98
#include "pyconfig.h" // Py_GIL_DISABLED
10-
#endif
119

1210
#ifndef Py_GIL_DISABLED
1311
#define Py_LIMITED_API 0x03050000

PC/layout/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def copy_if_modified(src, dest):
7373
)
7474

7575
if do_copy:
76-
shutil.copy2(src, dest)
76+
try:
77+
shutil.copy2(src, dest)
78+
except FileNotFoundError:
79+
raise FileNotFoundError(src) from None
7780

7881

7982
def get_lib_layout(ns):
@@ -208,8 +211,7 @@ def _c(d):
208211

209212
for dest, src in rglob(ns.source / "Include", "**/*.h"):
210213
yield "include/{}".format(dest), src
211-
src = ns.source / "PC" / "pyconfig.h"
212-
yield "include/pyconfig.h", src
214+
yield "include/pyconfig.h", ns.build / "pyconfig.h"
213215

214216
for dest, src in get_tcltk_lib(ns):
215217
yield dest, src

PC/pyconfig.h renamed to PC/pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,4 +739,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
739739
/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */
740740
#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1
741741

742+
/* Define if you want to disable the GIL */
743+
#undef Py_GIL_DISABLED
744+
742745
#endif /* !Py_CONFIG_H */

PC/winsound.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
winsound.PlaySound(None, 0)
3636
*/
3737

38+
#include "pyconfig.h" // Py_GIL_DISABLED
39+
3840
#ifndef Py_GIL_DISABLED
3941
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
4042
#define Py_LIMITED_API 0x030c0000

PCbuild/_freeze_module.vcxproj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
<ItemDefinitionGroup>
9090
<ClCompile>
9191
<PreprocessorDefinitions>Py_NO_ENABLE_SHARED;Py_BUILD_CORE;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
9293
<Optimization>Disabled</Optimization>
9394
<WholeProgramOptimization>false</WholeProgramOptimization>
9495
</ClCompile>
@@ -257,6 +258,9 @@
257258
<ClCompile Include="..\Python\traceback.c" />
258259
<ClCompile Include="..\Python\tracemalloc.c" />
259260
</ItemGroup>
261+
<ItemGroup>
262+
<ClInclude Include="..\PC\pyconfig.h.in" />
263+
</ItemGroup>
260264
<ItemGroup>
261265
<!-- BEGIN frozen modules -->
262266
<None Include="..\Lib\importlib\_bootstrap.py">
@@ -414,6 +418,32 @@
414418
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
415419
<ImportGroup Label="ExtensionTargets">
416420
</ImportGroup>
421+
422+
<!-- Direct copy from pythoncore.vcxproj, but this one is only used for our
423+
own build. All other extension modules will use the copy that pythoncore
424+
generates. -->
425+
<Target Name="_UpdatePyconfig" BeforeTargets="PrepareForBuild">
426+
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
427+
<ItemGroup>
428+
<PyConfigH Remove="@(PyConfigH)" />
429+
<PyConfigH Include="@(ClInclude)" Condition="'%(Filename)%(Extension)' == 'pyconfig.h.in'" />
430+
</ItemGroup>
431+
<Error Text="Did not find pyconfig.h" Condition="@(ClInclude) == ''" />
432+
<PropertyGroup>
433+
<PyConfigH>@(PyConfigH->'%(FullPath)', ';')</PyConfigH>
434+
<PyConfigHText>$([System.IO.File]::ReadAllText($(PyConfigH)))</PyConfigHText>
435+
<OldPyConfigH Condition="Exists('$(IntDir)pyconfig.h')">$([System.IO.File]::ReadAllText('$(IntDir)pyconfig.h'))</OldPyConfigH>
436+
</PropertyGroup>
437+
<PropertyGroup Condition="$(DisableGil) == 'true'">
438+
<PyConfigHText>$(PyConfigHText.Replace('#undef Py_GIL_DISABLED', '#define Py_GIL_DISABLED 1'))</PyConfigHText>
439+
</PropertyGroup>
440+
<Message Text="Updating pyconfig.h" Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
441+
<WriteLinesToFile File="$(IntDir)pyconfig.h"
442+
Lines="$(PyConfigHText)"
443+
Overwrite="true"
444+
Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
445+
</Target>
446+
417447
<Target Name="_RebuildGetPath" AfterTargets="_RebuildFrozen" Condition="$(Configuration) != 'PGUpdate'">
418448
<Exec Command='"$(TargetPath)" "%(GetPath.ModName)" "%(GetPath.FullPath)" "%(GetPath.IntFile)"' />
419449

PCbuild/pyproject.props

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<Py_IntDir Condition="'$(Py_IntDir)' == ''">$(MSBuildThisFileDirectory)obj\</Py_IntDir>
1111
<IntDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
1212
<IntDir>$(IntDir.Replace(`\\`, `\`))</IntDir>
13+
<!-- pyconfig.h is updated by pythoncore.vcxproj, so it's always in pythoncore's IntDir -->
14+
<GeneratedPyConfigDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\pythoncore\</GeneratedPyConfigDir>
1315
<TargetName Condition="'$(TargetName)' == ''">$(ProjectName)</TargetName>
1416
<TargetName>$(TargetName)$(PyDebugExt)</TargetName>
1517
<GenerateManifest>false</GenerateManifest>
@@ -38,9 +40,8 @@
3840
</PropertyGroup>
3941
<ItemDefinitionGroup>
4042
<ClCompile>
41-
<AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)Include\internal\mimalloc;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
43+
<AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)Include\internal\mimalloc;$(GeneratedPyConfigDir);$(PySourcePath)PC;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
4244
<PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition);$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
43-
<PreprocessorDefinitions Condition="'$(DisableGil)' == 'true'">Py_GIL_DISABLED=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
4445
<PreprocessorDefinitions Condition="'$(SupportPGO)' and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')">_Py_USING_PGO=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
4546

4647
<Optimization>MaxSpeed</Optimization>
@@ -60,6 +61,7 @@
6061
<AdditionalOptions Condition="$(PlatformToolset) == 'ClangCL'">-Wno-deprecated-non-prototype -Wno-unused-label -Wno-pointer-sign -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-function %(AdditionalOptions)</AdditionalOptions>
6162
<AdditionalOptions Condition="$(Configuration) != 'Debug' and $(PlatformToolset) == 'ClangCL'">-flto %(AdditionalOptions)</AdditionalOptions>
6263
<AdditionalOptions Condition="$(MSVCHasBrokenARM64Clamping) == 'true' and $(Platform) == 'ARM64'">-d2pattern-opt-disable:-932189325 %(AdditionalOptions)</AdditionalOptions>
64+
<AdditionalOptions Condition="$(GenerateSourceDependencies) == 'true'">/sourceDependencies "$(IntDir.Trim(`\`))" %(AdditionalOptions)</AdditionalOptions>
6365
</ClCompile>
6466
<ClCompile Condition="$(Configuration) == 'Debug'">
6567
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>

PCbuild/pythoncore.vcxproj

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
<ClInclude Include="..\Parser\string_parser.h" />
379379
<ClInclude Include="..\Parser\pegen.h" />
380380
<ClInclude Include="..\PC\errmap.h" />
381-
<ClInclude Include="..\PC\pyconfig.h" />
381+
<ClInclude Include="..\PC\pyconfig.h.in" />
382382
<ClInclude Include="..\Python\condvar.h" />
383383
<ClInclude Include="..\Python\stdlib_module_names.h" />
384384
<ClInclude Include="..\Python\thread_nt.h" />
@@ -646,6 +646,35 @@
646646
<Import Project="regen.targets" />
647647
</ImportGroup>
648648
<Target Name="_TriggerRegen" BeforeTargets="PrepareForBuild" DependsOnTargets="Regen" />
649+
650+
<Target Name="_UpdatePyconfig" BeforeTargets="PrepareForBuild">
651+
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
652+
<ItemGroup>
653+
<PyConfigH Remove="@(PyConfigH)" />
654+
<PyConfigH Include="@(ClInclude)" Condition="'%(Filename)%(Extension)' == 'pyconfig.h.in'" />
655+
</ItemGroup>
656+
<Error Text="Did not find pyconfig.h" Condition="@(ClInclude) == ''" />
657+
<PropertyGroup>
658+
<PyConfigH>@(PyConfigH->'%(FullPath)', ';')</PyConfigH>
659+
<PyConfigHText>$([System.IO.File]::ReadAllText($(PyConfigH)))</PyConfigHText>
660+
<OldPyConfigH Condition="Exists('$(IntDir)pyconfig.h')">$([System.IO.File]::ReadAllText('$(IntDir)pyconfig.h'))</OldPyConfigH>
661+
</PropertyGroup>
662+
<PropertyGroup Condition="$(DisableGil) == 'true'">
663+
<PyConfigHText>$(PyConfigHText.Replace('#undef Py_GIL_DISABLED', '#define Py_GIL_DISABLED 1'))</PyConfigHText>
664+
</PropertyGroup>
665+
<Message Text="Updating pyconfig.h" Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
666+
<WriteLinesToFile File="$(IntDir)pyconfig.h"
667+
Lines="$(PyConfigHText)"
668+
Overwrite="true"
669+
Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
670+
</Target>
671+
<Target Name="_CopyPyconfig" Inputs="$(IntDir)pyconfig.h" Outputs="$(OutDir)pyconfig.h" AfterTargets="Build" DependsOnTargets="_UpdatePyconfig">
672+
<Copy SourceFiles="$(IntDir)pyconfig.h" DestinationFolder="$(OutDir)" />
673+
</Target>
674+
<Target Name="_CleanPyconfig" AfterTargets="Clean">
675+
<Delete Files="$(IntDir)pyconfig.h;$(OutDir)pyconfig.h" />
676+
</Target>
677+
649678
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
650679
<PropertyGroup>
651680
<GIT Condition="$(GIT) == ''">git</GIT>

Tools/msi/dev/dev_files.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Fragment>
44
<ComponentGroup Id="dev_pyconfig">
55
<Component Id="include_pyconfig.h" Directory="include" Guid="*">
6-
<File Id="include_pyconfig.h" Name="pyconfig.h" Source="!(bindpath.src)PC\pyconfig.h" KeyPath="yes" />
6+
<File Id="include_pyconfig.h" Name="pyconfig.h" Source="pyconfig.h" KeyPath="yes" />
77
</Component>
88
</ComponentGroup>
99
</Fragment>

Tools/peg_generator/pegen/build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ def compile_c_extension(
143143
str(MOD_DIR.parent.parent.parent / "Parser" / "lexer"),
144144
str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer"),
145145
]
146+
if sys.platform == "win32":
147+
# HACK: The location of pyconfig.h has moved within our build, and
148+
# setuptools hasn't updated for it yet. So add the path manually for now
149+
include_dirs.append(pathlib.Path(sysconfig.get_config_h_filename()).parent)
146150
extension = Extension(
147151
extension_name,
148152
sources=[generated_source_path],

0 commit comments

Comments
 (0)