@@ -18,11 +18,12 @@ $srcRoot = Join-Path $workspace "windows\build"
1818$srcArchive = Join-Path $srcRoot " Python-$PythonVersion .tgz"
1919$srcDir = Join-Path $srcRoot " Python-$PythonVersion "
2020$pcbuildDir = Join-Path $srcDir " PCbuild\amd64"
21+ $pythonTag = $PythonVersionShort -replace ' \.' , ' '
2122
2223$packageRoot = Join-Path $workspace " windows\python-windows-for-dart-$PythonVersionShort "
2324$zipPath = Join-Path $workspace " windows\python-windows-for-dart-$PythonVersionShort .zip"
2425$excludeListPath = Join-Path $workspace " windows\python-windows-dart.exclude"
25- $keepImportLibs = @ (" python3.lib" , " python3_d.lib" , " python312 .lib" , " python312_d .lib" )
26+ $keepImportLibs = @ (" python3.lib" , " python3_d.lib" , " python $pythonTag .lib" , " python ${pythonTag} _d .lib" )
2627
2728New-Item - ItemType Directory - Force - Path $srcRoot | Out-Null
2829
@@ -49,10 +50,22 @@ New-Item -ItemType Directory -Force -Path "$packageRoot\DLLs", "$packageRoot\inc
4950Copy-Item - Path " $srcDir \Include\*" - Destination " $packageRoot \include" - Recurse - Force
5051Copy-Item - Path " $srcDir \Lib\*" - Destination " $packageRoot \Lib" - Recurse - Force
5152
52- # pyconfig.h is generated/platform-specific and lives under PC on Windows builds.
53- $pyconfigHeader = Join-Path $srcDir " PC\pyconfig.h"
54- if (-not (Test-Path $pyconfigHeader )) {
55- throw " Missing required header: $pyconfigHeader "
53+ # pyconfig.h location varies by CPython version/build layout.
54+ $pyconfigCandidates = @ (
55+ (Join-Path $srcDir " PC\pyconfig.h" ),
56+ (Join-Path $srcDir " Include\pyconfig.h" ),
57+ (Join-Path $pcbuildDir " pyconfig.h" )
58+ )
59+ $pyconfigHeader = $null
60+ foreach ($candidate in $pyconfigCandidates ) {
61+ if (Test-Path $candidate ) {
62+ $pyconfigHeader = $candidate
63+ break
64+ }
65+ }
66+ if (-not $pyconfigHeader ) {
67+ $candidateList = $pyconfigCandidates -join " , "
68+ throw " Missing required header. Checked: $candidateList "
5669}
5770Copy-Item - Path $pyconfigHeader - Destination " $packageRoot \include\pyconfig.h" - Force
5871
@@ -67,9 +80,9 @@ foreach ($name in @("LICENSE.txt", "NEWS.txt")) {
6780$rootFiles = @ (
6881 " python3.dll" ,
6982 " python3_d.dll" ,
70- " python312 .dll" ,
71- " python312_d .dll" ,
72- " python312_d .pdb" ,
83+ " python $pythonTag .dll" ,
84+ " python ${pythonTag} _d .dll" ,
85+ " python ${pythonTag} _d .pdb" ,
7386 " python_d.pdb" ,
7487 " pythonw_d.pdb"
7588)
@@ -93,7 +106,7 @@ foreach ($name in @("vcruntime140.dll", "vcruntime140_1.dll")) {
93106# Extension modules and supporting DLLs.
94107Get-ChildItem - Path $pcbuildDir - Filter " *.pyd" - File | Copy-Item - Destination " $packageRoot \DLLs" - Force
95108Get-ChildItem - Path $pcbuildDir - Filter " *.dll" - File |
96- Where-Object { $_.Name -notin @ (" python3.dll" , " python3_d.dll" , " python312 .dll" , " python312_d .dll" , " vcruntime140.dll" , " vcruntime140_1.dll" ) } |
109+ Where-Object { $_.Name -notin @ (" python3.dll" , " python3_d.dll" , " python $pythonTag .dll" , " python ${pythonTag} _d .dll" , " vcruntime140.dll" , " vcruntime140_1.dll" ) } |
97110 Copy-Item - Destination " $packageRoot \DLLs" - Force
98111foreach ($name in $keepImportLibs ) {
99112 $src = Join-Path $pcbuildDir $name
@@ -118,7 +131,7 @@ foreach ($pattern in $excludePatterns) {
118131}
119132
120133# Match existing packaging behavior: bytecode-only stdlib.
121- python - m compileall - b " $packageRoot \Lib"
134+ & $pythonFromPath - I - m compileall - b " $packageRoot \Lib"
122135Get-ChildItem - Path " $packageRoot \Lib" - Recurse - File - Include * .py, * .typed | Remove-Item - Force
123136Get-ChildItem - Path " $packageRoot \Lib" - Recurse - Directory - Filter __pycache__ | Remove-Item - Recurse - Force
124137
@@ -136,9 +149,9 @@ $requiredEntries = @(
136149 " $packageRoot \libs" ,
137150 " $packageRoot \python3.dll" ,
138151 " $packageRoot \python3_d.dll" ,
139- " $packageRoot \python312 .dll" ,
140- " $packageRoot \python312_d .dll" ,
141- " $packageRoot \python312_d .pdb" ,
152+ " $packageRoot \python $pythonTag .dll" ,
153+ " $packageRoot \python ${pythonTag} _d .dll" ,
154+ " $packageRoot \python ${pythonTag} _d .pdb" ,
142155 " $packageRoot \python_d.pdb" ,
143156 " $packageRoot \pythonw_d.pdb"
144157)
0 commit comments