Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
54ba2c0
gh-158948: Add auto-generated Module/getbuildinfo.h
vstinner Oct 6, 2026
508e3ca
Fix and reforamt generate_getbuildinfo.py
vstinner Oct 7, 2026
8e7fe03
Look for pyconfig.h in the current working directory
vstinner Oct 7, 2026
06cc348
Fix out-of-tree build
vstinner Oct 7, 2026
7c10d0b
Short comment
vstinner Oct 7, 2026
8c2dcce
Update PCbuild/_freeze_module.vcxproj
vstinner Oct 7, 2026
7882331
Update Tools/c-analyzer/cpython/ignored.tsv
vstinner Oct 7, 2026
22d1a6b
Don't redefine PY_VERSION
vstinner Oct 7, 2026
61ddc42
Remove useless getbuildinfo.h dependencies
vstinner Oct 7, 2026
1ae6b29
Add _getcompiler project on Windows
vstinner Oct 7, 2026
cd00cdb
Temporary workaround for cross-compilation
vstinner Oct 7, 2026
9a56153
Update PCbuild/pcbuild.proj
vstinner Oct 7, 2026
eab1b0e
Fix build when there is not .git/ directory (test_tools)
vstinner Oct 7, 2026
a0780d4
Enhance generate_getbuildinfo.py
vstinner Oct 7, 2026
0c8ad79
Run directly the compiler (--version) if _getcompiler failed
vstinner Oct 7, 2026
0d50e2e
Reuse sysconfig parsers
vstinner Oct 7, 2026
98519e1
Simplify _getcompiler build command
vstinner Oct 7, 2026
05a9779
Fix typo
vstinner Oct 7, 2026
11cd830
Strip URL from verbose Clang version
vstinner Oct 7, 2026
dc6d476
Strip '[ and ']' from COMPILER and _Py_COMPILER
vstinner Oct 7, 2026
ad75107
Tolerate "cc --version" failure, use "C" compiler by default
vstinner Oct 7, 2026
4281ae9
Cleanup get_compiler() code
vstinner Oct 8, 2026
d6fd2d4
Shorter clang version; add tests
vstinner Oct 8, 2026
aa9a4aa
Fix test
vstinner Oct 8, 2026
b036e72
Keep the vendor (Android or Apple) in Clang version
vstinner Oct 8, 2026
1d9bb17
Revert unrelated changes
vstinner Oct 8, 2026
ebaadbc
Log the truncated compiler string
vstinner Oct 8, 2026
2c9bafb
Support old sysconfig versions
vstinner Oct 8, 2026
8431d21
Fix Makefile (_getcompiler) for BSD make
vstinner Oct 8, 2026
e53aa5d
Do not truncate compiler versions generated by PC/pyconfig.h
vstinner Oct 9, 2026
3b179ca
generate_getbuildinfo.py now runs git commands on Windows
vstinner Oct 9, 2026
556de20
generate_getbuildinfo.py now runs _getcompiler program on Windows
vstinner Oct 9, 2026
874ce6d
Update tests
vstinner Oct 9, 2026
db0495d
Please the lords of linters
vstinner Oct 9, 2026
3cc52ef
Build FreezeProjects with Platform, not PreferredToolArchitecture
vstinner Oct 9, 2026
8feb3ad
Update test on Windows
vstinner Oct 9, 2026
dffcfb8
On Windows, get the C compiler version if running _getcompiler fails
vstinner Oct 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add _getcompiler project on Windows
  • Loading branch information
vstinner committed Oct 7, 2026
commit 1ae6b29b4481f5c3a7ac58f4bbef5f18c2763c09
3 changes: 2 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,8 @@ Modules/getbuildinfo.h: $(srcdir)/Tools/build/generate_getbuildinfo.py Programs/
`LC_ALL=C $(GITVERSION)` \
`LC_ALL=C $(GITTAG)` \
`LC_ALL=C $(GITBRANCH)` \
"`Programs/_getcompiler`"
"`Programs/_getcompiler`" \
use_pyconfig

Modules/getbuildinfo.o: $(srcdir)/Modules/getbuildinfo.c Modules/getbuildinfo.h
# Add local Modules/ include directory to get Modules/getbuildinfo.h
Expand Down
116 changes: 116 additions & 0 deletions PCbuild/_getcompiler.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|ARM">
<Configuration>PGInstrument</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|ARM64">
<Configuration>PGInstrument</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|Win32">
<Configuration>PGInstrument</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|x64">
<Configuration>PGInstrument</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|ARM">
<Configuration>PGUpdate</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|ARM64">
<Configuration>PGUpdate</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|Win32">
<Configuration>PGUpdate</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|x64">
<Configuration>PGUpdate</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E762E8EE-5316-4D66-9529-7074F3B6E74A}</ProjectGuid>
<RootNamespace>_getcompiler</RootNamespace>
<SupportPGO>false</SupportPGO>
</PropertyGroup>
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<TargetName>_getcompiler</TargetName>
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup>
<MakeVersionInfoBeforeTarget>ClCompile</MakeVersionInfoBeforeTarget>
</PropertyGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="pyproject.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros">
<ExeName>$(PyExeName).exe</ExeName>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>EXENAME=L"$(ExeName)";_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>PY_ICON;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Programs\_getcompiler.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_exe.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
21 changes: 21 additions & 0 deletions PCbuild/_getcompiler.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resource Files">
<UniqueIdentifier>{8f3ab79e-3cba-4e6d-82b2-559ce946de58}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4a2423af-e5d1-4c88-b308-d71b768977df}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_exe.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Programs\_getcompiler.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
41 changes: 38 additions & 3 deletions PCbuild/pcbuild.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
# Visual Studio Version 18
VisualStudioVersion = 18.10.12224.181 stable
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -33,8 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj",
{78D80A15-BD8C-44E2-B49E-1F05B0A0A687} = {78D80A15-BD8C-44E2-B49E-1F05B0A0A687}
{86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480}
{885D4898-D08D-4091-9C40-C700CFE3FC5A} = {885D4898-D08D-4091-9C40-C700CFE3FC5A}
{947BB5F5-6025-4A4F-8182-1B175469F8D2} = {947BB5F5-6025-4A4F-8182-1B175469F8D2}
{900342D7-516A-4469-B1AD-59A66E49A25F} = {900342D7-516A-4469-B1AD-59A66E49A25F}
{947BB5F5-6025-4A4F-8182-1B175469F8D2} = {947BB5F5-6025-4A4F-8182-1B175469F8D2}
{9E48B300-37D1-11DD-8C41-005056C00008} = {9E48B300-37D1-11DD-8C41-005056C00008}
{9EC7190A-249F-4180-A900-548FDCF3055F} = {9EC7190A-249F-4180-A900-548FDCF3055F}
{A2697BD3-28C1-4AEC-9106-8B748639FD16} = {A2697BD3-28C1-4AEC-9106-8B748639FD16}
Expand All @@ -43,6 +43,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj",
{C6E20F84-3247-4AD6-B051-B073268F73BA} = {C6E20F84-3247-4AD6-B051-B073268F73BA}
{CB435430-EBB1-478B-8F4E-C256F6838F55} = {CB435430-EBB1-478B-8F4E-C256F6838F55}
{D06B6426-4762-44CC-8BAD-D79052507F2F} = {D06B6426-4762-44CC-8BAD-D79052507F2F}
{E762E8EE-5316-4D66-9529-7074F3B6E74A} = {E762E8EE-5316-4D66-9529-7074F3B6E74A}
{EB6E69DD-04BF-4543-9B92-49FAABCEAC2E} = {EB6E69DD-04BF-4543-9B92-49FAABCEAC2E}
{ECC7CEAC-A5E5-458E-BB9E-2413CC847881} = {ECC7CEAC-A5E5-458E-BB9E-2413CC847881}
{F749B822-B489-4CA5-A3AD-CE078F5F338A} = {F749B822-B489-4CA5-A3AD-CE078F5F338A}
Expand Down Expand Up @@ -161,6 +162,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_zstd", "_zstd.vcxproj", "{
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xxlimited_35", "xxlimited_35.vcxproj", "{FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_getcompiler", "_getcompiler.vcxproj", "{E762E8EE-5316-4D66-9529-7074F3B6E74A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Expand Down Expand Up @@ -1746,6 +1749,38 @@ Global
{FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|Win32.Build.0 = Release|Win32
{FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|x64.ActiveCfg = Release|x64
{FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|x64.Build.0 = Release|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|ARM.ActiveCfg = Debug|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|ARM.Build.0 = Debug|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|ARM64.ActiveCfg = Debug|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|ARM64.Build.0 = Debug|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|Win32.ActiveCfg = Debug|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|Win32.Build.0 = Debug|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|x64.ActiveCfg = Debug|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Debug|x64.Build.0 = Debug|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|ARM.Build.0 = PGInstrument|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|Win32.Build.0 = PGInstrument|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|x64.ActiveCfg = PGInstrument|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGInstrument|x64.Build.0 = PGInstrument|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|ARM.Build.0 = PGUpdate|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|Win32.Build.0 = PGUpdate|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|x64.ActiveCfg = PGUpdate|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.PGUpdate|x64.Build.0 = PGUpdate|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|ARM.ActiveCfg = Release|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|ARM.Build.0 = Release|ARM
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|ARM64.ActiveCfg = Release|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|ARM64.Build.0 = Release|ARM64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|Win32.ActiveCfg = Release|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|Win32.Build.0 = Release|Win32
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|x64.ActiveCfg = Release|x64
{E762E8EE-5316-4D66-9529-7074F3B6E74A}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions PCbuild/python.props
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
<PyExeName Condition="$(PyExeName) == ''">python</PyExeName>
<PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)$(PyExeName)$(PyDebugExt).exe</PythonExe>
<PyWExeName Condition="$(PyWExeName) == ''">pythonw</PyWExeName>
<GetCompilerExe Condition="'$(GetCompilerExe)' == ''">$(BuildPath)_getcompiler$(PyDebugExt).exe</GetCompilerExe>

<!-- The name of the resulting pythonXY.dll (without the extension) -->
<PyDllName Condition="$(DisableGil) == 'true'">python$(MajorVersionNumber)$(MinorVersionNumber)t$(PyDebugExt)</PyDllName>
Expand Down
21 changes: 14 additions & 7 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,10 @@
</ImportGroup>
<Target Name="_TriggerRegen" BeforeTargets="PrepareForBuild" DependsOnTargets="Regen" />

<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
<Target Name="_GetBuildInfoHeader"
Inputs="" Outputs="Modules\getbuildinfo.h"
DependsOnTargets="FindPythonForBuild"
BeforeTargets="PrepareForBuild">
<PropertyGroup>
<GIT Condition="$(GIT) == ''">git</GIT>
<_GIT>$(GIT)</_GIT>
Expand All @@ -742,18 +745,22 @@
<Exec Command="$(_GIT) name-rev --name-only HEAD &gt; &quot;$(IntDir)gitbranch.txt&quot;" ContinueOnError="true" />
<Exec Command="$(_GIT) rev-parse --short HEAD &gt; &quot;$(IntDir)gitversion.txt&quot;" ContinueOnError="true" />
<Exec Command="$(_GIT) describe --all --always --dirty &gt; &quot;$(IntDir)gittag.txt&quot;" ContinueOnError="true" />
<Exec Command='"$(GetCompilerExe)" &gt; &quot;$(IntDir)compiler.txt&quot;' ContinueOnError="true" />
<PropertyGroup>
<GitBranch Condition="Exists('$(IntDir)gitbranch.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitbranch.txt').Trim())</GitBranch>
<GitVersion Condition="Exists('$(IntDir)gitversion.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gitversion.txt').Trim())</GitVersion>
<GitTag Condition="Exists('$(IntDir)gittag.txt')">$([System.IO.File]::ReadAllText('$(IntDir)gittag.txt').Trim())</GitTag>
<Compiler Condition="Exists('$(IntDir)compiler.txt')">$([System.IO.File]::ReadAllText('$(IntDir)compiler.txt').Trim())</Compiler>

<GilEnabled Condition="$(DisableGil) == 'true'">0</GilEnabled>
<GilEnabled Condition="$(DisableGil) != 'true'">1</GilEnabled>
</PropertyGroup>
<Message Text="Building $(GitTag):$(GitVersion) $(GitBranch)" Importance="high" />
<ItemGroup>
<ClCompile Condition="%(Filename) == 'getbuildinfo'">
<PreprocessorDefinitions>GITVERSION="$(GitVersion)";GITTAG="$(GitTag)";GITBRANCH="$(GitBranch)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>

<Message Text="Run generate_getbuildinfo.py" Importance="high" />
<Exec Command='$(PythonForBuild) Tools/build/generate_getbuildinfo.py Modules\getbuildinfo.h win32 $(GitVersion) $(GitTag) $(GitBranch) "$(Compiler)" $(GilEnabled)'
WorkingDirectory="$(PySourcePath)" />
</Target>

<Target Name="_WarnAboutToolset" BeforeTargets="PrepareForBuild" Condition="$(PlatformToolset) != 'v143' and $(PlatformToolset) != 'v145'">
<Warning Text="Toolset $(PlatformToolset) is not used for official builds. Your build may have errors or incompatibilities." />
</Target>
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ pythonw
_testembed
_testembed.exe, a small program that embeds Python for testing
purposes, used by test_capi.py
_getcompiler
_getcompiler.exe, a small program that writes the compiler name and version
to stdout. Used to build Modules\getbuildinfo.h.

These are miscellaneous sub-projects that don't really fit the other
categories:
Expand Down
3 changes: 3 additions & 0 deletions Programs/_getcompiler.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Do not link to python3x.lib
#define Py_NO_LINK_LIB

#include "Python.h"
#include <stdio.h> // printf()

Expand Down
15 changes: 9 additions & 6 deletions Tools/build/generate_getbuildinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ def get_date_time():


def main():
if len(sys.argv) != 7:
if len(sys.argv) != 8:
print(f"usage: {SCRIPT_NAME} "
"OUTPUT PLATFORM GITVERSION GITTAG GITBRANCH COMPILER")
print(sys.argv)
print(len(sys.argv))
"OUTPUT PLATFORM GITVERSION GITTAG GITBRANCH COMPILER GIL_ENABLED")
sys.exit(1)

OUTPUT = sys.argv[1]
Expand All @@ -73,6 +71,7 @@ def main():
GITTAG = sys.argv[4]
GITBRANCH = sys.argv[5]
COMPILER = sys.argv[6]
GIL_ENABLED = sys.argv[7]

if not PLATFORM:
PLATFORM = "unknown"
Expand All @@ -93,10 +92,14 @@ def main():

DATE, TIME = get_date_time()
PY_VERSION = get_py_version()
Py_GIL_DISABLED = get_gil_disable()
if GIL_ENABLED == 'use_pyconfig':
Py_GIL_DISABLED = get_gil_disable()
GIL_ENABLED = not Py_GIL_DISABLED
else:
GIL_ENABLED = int(GIL_ENABLED)
BUILDINFO = f"{gitid}{sep}{revision}, {DATE:.20s}, {TIME:.9s}"

if Py_GIL_DISABLED:
if not GIL_ENABLED:
GET_VERSION = f"{PY_VERSION} free-threading build ({BUILDINFO}) {COMPILER}"
else:
GET_VERSION = f"{PY_VERSION} ({BUILDINFO}) {COMPILER}"
Expand Down