[eric] perf: strip type stubs + unix build leftovers from the bundled python so defender frisks fewer files

This commit is contained in:
Eric
2026-05-27 13:00:15 -07:00
parent 0d4dbd35df
commit b544a9264e
2 changed files with 13 additions and 0 deletions
+5
View File
@@ -160,6 +160,11 @@ foreach ($pattern in @('RECORD','INSTALLER','WHEEL','top_level.txt','entry_point
| Remove-Item -Force -ErrorAction SilentlyContinue
}
# ----- type stubs (.pyi) — read only by type-checkers, never at runtime -----
Write-Host "Trimming .pyi type stubs..."
Get-ChildItem -Path $PythonEnvDir -Recurse -Filter '*.pyi' -File -ErrorAction SilentlyContinue `
| Remove-Item -Force -ErrorAction SilentlyContinue
# Pre-compile bytecode so cold backend startup skips parse+compile on
# every imported .py. Worth ~5-10s on Windows under Defender (parsing
# Python source is parser-bound; loading .pyc is just bytes). We cap
+8
View File
@@ -207,6 +207,14 @@ find "$SP" -path '*.dist-info/WHEEL' -delete 2>/dev/null
find "$SP" -path '*.dist-info/top_level.txt' -delete 2>/dev/null
find "$SP" -path '*.dist-info/entry_points.txt' -delete 2>/dev/null
# ----- type stubs + build leftovers (more files off Defender's plate) -----
# .pyi stubs are read only by type-checkers, never by the running interpreter.
find "$PYTHON_ENV_DIR" -name '*.pyi' -delete 2>/dev/null || true
# Unix build artifacts: the static lib + config Makefiles exist only to compile
# C extensions / embed Python; the running interpreter never reads them.
rm -rf "$PYTHON_ENV_DIR"/lib/python3.13/config-3.13-* 2>/dev/null || true
find "$PYTHON_ENV_DIR" -name 'libpython*.a' -delete 2>/dev/null || true
# Pre-compile bytecode so cold backend startup skips the parse+compile
# step on every imported .py. Worth ~5-10s on Windows under Defender
# (parsing Python source is parser-bound; loading .pyc is just bytes).