@@ -107,142 +107,7 @@ jobs:
107107 - name : Build CPython from sources and package for Dart
108108 shell : pwsh
109109 run : |
110- $ErrorActionPreference = "Stop"
111-
112- $pyVer = "${{ env.PYTHON_VERSION }}"
113- $pyShort = "${{ env.PYTHON_VERSION_SHORT }}"
114- $workspace = $env:GITHUB_WORKSPACE
115-
116- $srcRoot = Join-Path $workspace "windows\build"
117- $srcArchive = Join-Path $srcRoot "Python-$pyVer.tgz"
118- $srcDir = Join-Path $srcRoot "Python-$pyVer"
119- $pcbuildDir = Join-Path $srcDir "PCbuild\amd64"
120-
121- $packageRoot = Join-Path $workspace "windows\python-windows-for-dart-$pyShort"
122- $zipPath = Join-Path $workspace "windows\python-windows-for-dart-$pyShort.zip"
123-
124- # Cleanup/include lists kept in one place for visibility and maintenance.
125- $pruneLibDirs = @("test", "idlelib", "tkinter", "turtledemo", "ensurepip", "pydoc_data", "lib2to3")
126- $pruneDllPatterns = @("_test*.pyd", "_ctypes_test*.pyd", "_tkinter*.pyd", "xxlimited*.pyd")
127- $pruneDllFiles = @("tcl86t.dll", "tk86t.dll", "zlib1.dll", "pyshellext.dll", "pyshellext_d.dll")
128- $keepImportLibs = @("python3.lib", "python3_d.lib", "python312.lib", "python312_d.lib")
129- $pruneSitePackagesPatterns = @("pip*", "setuptools*", "wheel*")
130-
131- New-Item -ItemType Directory -Force -Path $srcRoot | Out-Null
132-
133- Write-Host "Downloading CPython source $pyVer"
134- Invoke-WebRequest -Uri "https://www.python.org/ftp/python/$pyVer/Python-$pyVer.tgz" -OutFile $srcArchive
135- tar -xf $srcArchive -C $srcRoot
136-
137- Push-Location $srcDir
138- cmd /c "PCbuild\build.bat -e -p x64 -c Release"
139- cmd /c "PCbuild\build.bat -e -p x64 -c Debug"
140- Pop-Location
141-
142- Remove-Item -Recurse -Force $packageRoot -ErrorAction SilentlyContinue
143- New-Item -ItemType Directory -Force -Path "$packageRoot\DLLs", "$packageRoot\include", "$packageRoot\Lib", "$packageRoot\libs", "$packageRoot\Scripts" | Out-Null
144-
145- Copy-Item -Path "$srcDir\Include\*" -Destination "$packageRoot\include" -Recurse -Force
146- Copy-Item -Path "$srcDir\Lib\*" -Destination "$packageRoot\Lib" -Recurse -Force
147-
148- # Root binaries and symbols.
149- foreach ($name in @("LICENSE.txt", "NEWS.txt")) {
150- $src = Join-Path $srcDir $name
151- if (Test-Path $src) {
152- Copy-Item -Path $src -Destination $packageRoot -Force
153- }
154- }
155-
156- $rootFiles = @(
157- "python3.dll",
158- "python3_d.dll",
159- "python312.dll",
160- "python312_d.dll",
161- "python312_d.pdb",
162- "python_d.pdb",
163- "pythonw_d.pdb"
164- )
165- foreach ($name in $rootFiles) {
166- $src = Join-Path $pcbuildDir $name
167- if (Test-Path $src) {
168- Copy-Item -Path $src -Destination $packageRoot -Force
169- }
170- }
171-
172- foreach ($name in @("vcruntime140.dll", "vcruntime140_1.dll")) {
173- $fromBuild = Join-Path $pcbuildDir $name
174- $fromSystem = Join-Path "$env:WINDIR\System32" $name
175- if (Test-Path $fromBuild) {
176- Copy-Item -Path $fromBuild -Destination $packageRoot -Force
177- } elseif (Test-Path $fromSystem) {
178- Copy-Item -Path $fromSystem -Destination $packageRoot -Force
179- }
180- }
181-
182- # Extension modules and supporting DLLs.
183- Get-ChildItem -Path $pcbuildDir -Filter "*.pyd" -File | Copy-Item -Destination "$packageRoot\DLLs" -Force
184- Get-ChildItem -Path $pcbuildDir -Filter "*.dll" -File |
185- Where-Object { $_.Name -notin @("python3.dll", "python3_d.dll", "python312.dll", "python312_d.dll", "vcruntime140.dll", "vcruntime140_1.dll") } |
186- Copy-Item -Destination "$packageRoot\DLLs" -Force
187- Get-ChildItem -Path $pcbuildDir -Filter "*.lib" -File | Copy-Item -Destination "$packageRoot\libs" -Force
188-
189- # Cleanup to keep package close to the original installer-based zip size/layout.
190- foreach ($dirName in $pruneLibDirs) {
191- $dirPath = Join-Path "$packageRoot\Lib" $dirName
192- if (Test-Path $dirPath) {
193- Remove-Item -Recurse -Force $dirPath
194- }
195- }
196- $sitePackagesDir = Join-Path "$packageRoot\Lib" "site-packages"
197- if (Test-Path $sitePackagesDir) {
198- foreach ($pattern in $pruneSitePackagesPatterns) {
199- Get-ChildItem -Path $sitePackagesDir -Filter $pattern -Force -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force
200- }
201- }
202-
203- foreach ($pattern in $pruneDllPatterns) {
204- Get-ChildItem -Path "$packageRoot\DLLs" -Filter $pattern -File -ErrorAction SilentlyContinue | Remove-Item -Force
205- }
206- foreach ($name in $pruneDllFiles) {
207- $filePath = Join-Path "$packageRoot\DLLs" $name
208- if (Test-Path $filePath) {
209- Remove-Item -Force $filePath
210- }
211- }
212-
213- Get-ChildItem -Path "$packageRoot\libs" -Filter "*.lib" -File |
214- Where-Object { $_.Name -notin $keepImportLibs } |
215- Remove-Item -Force
216-
217- # Match existing packaging behavior: bytecode-only stdlib.
218- py -3 -m compileall -b "$packageRoot\Lib"
219- Get-ChildItem -Path "$packageRoot\Lib" -Recurse -File -Include *.py,*.typed | Remove-Item -Force
220- Get-ChildItem -Path "$packageRoot\Lib" -Recurse -Directory -Filter __pycache__ | Remove-Item -Recurse -Force
221-
222- # Fail fast if required layout entries are missing.
223- $requiredEntries = @(
224- "$packageRoot\DLLs",
225- "$packageRoot\include",
226- "$packageRoot\Lib",
227- "$packageRoot\libs",
228- "$packageRoot\Scripts",
229- "$packageRoot\python3.dll",
230- "$packageRoot\python3_d.dll",
231- "$packageRoot\python312.dll",
232- "$packageRoot\python312_d.dll",
233- "$packageRoot\python312_d.pdb",
234- "$packageRoot\python_d.pdb",
235- "$packageRoot\pythonw_d.pdb"
236- )
237- foreach ($entry in $requiredEntries) {
238- if (-not (Test-Path $entry)) {
239- ls $packageRoot
240- throw "Missing required package entry: $entry"
241- }
242- }
243-
244- Remove-Item -Force $zipPath -ErrorAction SilentlyContinue
245- 7z a $zipPath "$packageRoot\*"
110+ .\windows\package-for-dart.ps1 -PythonVersion "${{ env.PYTHON_VERSION }}" -PythonVersionShort "${{ env.PYTHON_VERSION_SHORT }}"
246111 - uses : actions/upload-artifact@v4
247112 with :
248113 name : python-windows
0 commit comments