Skip to content

Commit f7b2476

Browse files
committed
Prune unnecessary files from Windows Python package
Centralize lists of files/dirs to remove and prune the Windows packaging output before zipping. Adds variables for lib dirs, DLL filename patterns, specific DLLs, and import libs to keep, then removes test/idlelib/tkinter/turtledemo dirs, unwanted *.pyd DLLs, listed DLL files, and non-kept .lib files from the package. This keeps the produced zip closer to the installer layout/size and makes cleanup lists easier to maintain.
1 parent ff063fd commit f7b2476

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/build-python.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ jobs:
121121
$packageRoot = Join-Path $workspace "windows\python-windows-for-dart-$pyShort"
122122
$zipPath = Join-Path $workspace "windows\python-windows-for-dart-$pyShort.zip"
123123
124+
# Cleanup/include lists kept in one place for visibility and maintenance.
125+
$pruneLibDirs = @("test", "idlelib", "tkinter", "turtledemo")
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+
124130
New-Item -ItemType Directory -Force -Path $srcRoot | Out-Null
125131
126132
Write-Host "Downloading CPython source $pyVer"
@@ -179,6 +185,28 @@ jobs:
179185
Copy-Item -Destination "$packageRoot\DLLs" -Force
180186
Get-ChildItem -Path $pcbuildDir -Filter "*.lib" -File | Copy-Item -Destination "$packageRoot\libs" -Force
181187
188+
# Cleanup to keep package close to the original installer-based zip size/layout.
189+
foreach ($dirName in $pruneLibDirs) {
190+
$dirPath = Join-Path "$packageRoot\Lib" $dirName
191+
if (Test-Path $dirPath) {
192+
Remove-Item -Recurse -Force $dirPath
193+
}
194+
}
195+
196+
foreach ($pattern in $pruneDllPatterns) {
197+
Get-ChildItem -Path "$packageRoot\DLLs" -Filter $pattern -File -ErrorAction SilentlyContinue | Remove-Item -Force
198+
}
199+
foreach ($name in $pruneDllFiles) {
200+
$filePath = Join-Path "$packageRoot\DLLs" $name
201+
if (Test-Path $filePath) {
202+
Remove-Item -Force $filePath
203+
}
204+
}
205+
206+
Get-ChildItem -Path "$packageRoot\libs" -Filter "*.lib" -File |
207+
Where-Object { $_.Name -notin $keepImportLibs } |
208+
Remove-Item -Force
209+
182210
# Match existing packaging behavior: bytecode-only stdlib.
183211
py -3 -m compileall -b "$packageRoot\Lib"
184212
Get-ChildItem -Path "$packageRoot\Lib" -Recurse -File -Include *.py,*.typed | Remove-Item -Force

0 commit comments

Comments
 (0)