Skip to content

Commit e77e017

Browse files
committed
Prune empty dirs and drop Scripts requirement
Add a post-cleanup step to remove empty directories left after exclusions and cleanup (recursively, sorting by path length to remove nested dirs first). Also remove "$packageRoot\Scripts" from the required layout entries so the script no longer fails if that folder is absent.
1 parent 3da5a6c commit e77e017

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

windows/package-for-dart.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,18 @@ py -3 -m compileall -b "$packageRoot\Lib"
114114
Get-ChildItem -Path "$packageRoot\Lib" -Recurse -File -Include *.py,*.typed | Remove-Item -Force
115115
Get-ChildItem -Path "$packageRoot\Lib" -Recurse -Directory -Filter __pycache__ | Remove-Item -Recurse -Force
116116

117+
# Remove empty directories left after exclusions/cleanup.
118+
Get-ChildItem -Path $packageRoot -Recurse -Directory |
119+
Sort-Object { $_.FullName.Length } -Descending |
120+
Where-Object { (Get-ChildItem -Path $_.FullName -Force | Measure-Object).Count -eq 0 } |
121+
Remove-Item -Force
122+
117123
# Fail fast if required layout entries are missing.
118124
$requiredEntries = @(
119125
"$packageRoot\DLLs",
120126
"$packageRoot\include",
121127
"$packageRoot\Lib",
122128
"$packageRoot\libs",
123-
"$packageRoot\Scripts",
124129
"$packageRoot\python3.dll",
125130
"$packageRoot\python3_d.dll",
126131
"$packageRoot\python312.dll",

0 commit comments

Comments
 (0)