Skip to content

Commit 708308a

Browse files
committed
Make clean opt-in and suppress UCRT API-set false positives
1 parent 0cbc83e commit 708308a

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

dev/_installers/all_deps.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ def default_search_dirs(target: Path, extra_dirs):
3636
out.append(d)
3737
return out
3838

39+
40+
41+
def has_ucrtbase(search_dirs):
42+
for d in search_dirs:
43+
if (d / "ucrtbase.dll").is_file():
44+
return True
45+
return False
46+
47+
48+
def is_ucrt_apiset(dll_name: str) -> bool:
49+
name = dll_name.lower()
50+
return name.startswith("api-ms-win-crt-") and name.endswith(".dll")
51+
52+
3953
def resolve_dll(name: str, search_dirs):
4054
# If it’s already an absolute path
4155
p = Path(name)
@@ -49,7 +63,7 @@ def resolve_dll(name: str, search_dirs):
4963
return cand.resolve()
5064
return None
5165

52-
def walk(pe_path: Path, search_dirs, indent=0):
66+
def walk(pe_path: Path, search_dirs, indent=0, ucrtbase_present=False):
5367
pe_path = pe_path.resolve()
5468
key = str(pe_path).lower()
5569
if key in VISITED:
@@ -64,14 +78,17 @@ def walk(pe_path: Path, search_dirs, indent=0):
6478
for dll in imports:
6579
hit = resolve_dll(dll, search_dirs)
6680
if hit is None:
81+
if ucrtbase_present and is_ucrt_apiset(dll):
82+
print(f"{pad} OK(APISET): {dll} (ucrtbase.dll present)")
83+
continue
6784
missing += 1
6885
print(f"{pad} MISSING: {dll}")
6986
else:
7087
print(f"{pad} OK: {dll} -> {hit}")
7188
# Recurse only into non-system DLLs (heuristic)
7289
if "windows\\system32" not in str(hit).lower():
7390
try:
74-
walk(hit, search_dirs, indent + 1)
91+
walk(hit, search_dirs, indent + 1, ucrtbase_present=ucrtbase_present)
7592
except pefile.PEFormatError:
7693
pass
7794

@@ -87,4 +104,7 @@ def walk(pe_path: Path, search_dirs, indent=0):
87104
extra = [Path(p) for p in sys.argv[2:]]
88105

89106
search_dirs = default_search_dirs(target, extra)
90-
walk(target, search_dirs)
107+
ucrtbase_present = has_ucrtbase(search_dirs)
108+
if ucrtbase_present:
109+
print("INFO: ucrtbase.dll detected in search dirs; treating api-ms-win-crt-*.dll as API-set forwarders.")
110+
walk(target, search_dirs, ucrtbase_present=ucrtbase_present)

dev/_installers/build_installer.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# Build IBEIS with PyInstaller (onedir) and optionally produce Inno Setup installer.
33
# Run from repo root:
44
# powershell -ExecutionPolicy Bypass -File .\dev\_installers\build_installer.ps1 -SmokeTest
5+
# Optional cleanup (opt-in): add -Clean
56

67
[CmdletBinding()]
78
param(
8-
[switch]$NoClean,
9+
[switch]$Clean,
910
[switch]$SkipPyInstaller,
1011
[switch]$SkipInno,
1112
[switch]$SmokeTest,
@@ -90,7 +91,7 @@ try {
9091
& $VenvPy -m pip install -U PyInstaller pywin32-ctypes pefile | Out-Host
9192
& $VenvPy -c "import win32ctypes.pywin32; import win32ctypes.pywin32.win32api, win32ctypes.pywin32.pywintypes; print('win32ctypes OK')" | Out-Host
9293

93-
if (-not $NoClean) {
94+
if ($Clean) {
9495
Write-Section "Clean build/dist"
9596
Remove-Item -Recurse -Force (Join-Path $RepoRoot "build"), (Join-Path $RepoRoot "dist") -ErrorAction SilentlyContinue
9697
New-Item -ItemType Directory -Force $DistDir | Out-Null

0 commit comments

Comments
 (0)