Skip to content

Commit 6a83985

Browse files
committed
Fix download_windows_dlls: handle gh subdirectory, copy with rglob
1 parent 4ebcc3f commit 6a83985

1 file changed

Lines changed: 33 additions & 18 deletions

File tree

scripts/create-release.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def bump_version_files(tag):
8181

8282
def download_windows_dlls():
8383
"""Download bundled Windows runtime DLLs from latest CI run."""
84-
import subprocess, json
84+
import subprocess, json, shutil
85+
from pathlib import Path
8586
repo = "processing-cpp/processing.cpp"
8687
r = subprocess.run(
8788
["gh", "run", "list", "--repo", repo, "--workflow", "build-cache.yml",
@@ -91,14 +92,20 @@ def download_windows_dlls():
9192
run_id = json.loads(r.stdout)[0]["databaseId"]
9293
dest = Path(__file__).parent.parent / "libs" / "windows-x64"
9394
dest.mkdir(parents=True, exist_ok=True)
94-
result = subprocess.run(
95-
["gh", "run", "download", str(run_id), "--repo", repo,
96-
"--name", "windows-runtime-dlls", "--dir", str(dest)],
97-
capture_output=True, text=True)
98-
if result.returncode == 0:
99-
print(f" windows runtime DLLs downloaded to {dest}")
100-
else:
101-
print(f" WARNING: could not download windows runtime DLLs")
95+
# Download to a temp dir first since gh may create subdirectory
96+
import tempfile
97+
with tempfile.TemporaryDirectory() as tmp:
98+
result = subprocess.run(
99+
["gh", "run", "download", str(run_id), "--repo", repo,
100+
"--name", "windows-runtime-dlls", "--dir", tmp],
101+
capture_output=True, text=True)
102+
if result.returncode != 0:
103+
print(f" WARNING: could not download windows runtime DLLs: {result.stderr}")
104+
return
105+
# Copy all DLLs to dest
106+
for dll in Path(tmp).rglob("*.dll"):
107+
shutil.copy2(dll, dest / dll.name)
108+
print(f" copied {dll.name} to libs/windows-x64/")
102109

103110
def trigger_and_wait_cache_build():
104111
"""Trigger a new build-cache CI run and wait for it to complete."""
@@ -137,6 +144,7 @@ def download_cache_artifacts():
137144
"""Download precompiled .o files from latest successful build-cache CI run."""
138145
import subprocess, json
139146
from pathlib import Path
147+
from pathlib import Path
140148
repo = "processing-cpp/processing.cpp"
141149
root = Path(__file__).parent.parent
142150
platforms = ["linux-x64", "windows-x64", "macos-arm64", "macos-x64"]
@@ -174,7 +182,8 @@ def download_cache_artifacts():
174182

175183
def download_windows_dlls():
176184
"""Download bundled Windows runtime DLLs from latest CI run."""
177-
import subprocess, json
185+
import subprocess, json, shutil
186+
from pathlib import Path
178187
repo = "processing-cpp/processing.cpp"
179188
r = subprocess.run(
180189
["gh", "run", "list", "--repo", repo, "--workflow", "build-cache.yml",
@@ -184,14 +193,20 @@ def download_windows_dlls():
184193
run_id = json.loads(r.stdout)[0]["databaseId"]
185194
dest = Path(__file__).parent.parent / "libs" / "windows-x64"
186195
dest.mkdir(parents=True, exist_ok=True)
187-
result = subprocess.run(
188-
["gh", "run", "download", str(run_id), "--repo", repo,
189-
"--name", "windows-runtime-dlls", "--dir", str(dest)],
190-
capture_output=True, text=True)
191-
if result.returncode == 0:
192-
print(f" windows runtime DLLs downloaded to {dest}")
193-
else:
194-
print(f" WARNING: could not download windows runtime DLLs")
196+
# Download to a temp dir first since gh may create subdirectory
197+
import tempfile
198+
with tempfile.TemporaryDirectory() as tmp:
199+
result = subprocess.run(
200+
["gh", "run", "download", str(run_id), "--repo", repo,
201+
"--name", "windows-runtime-dlls", "--dir", tmp],
202+
capture_output=True, text=True)
203+
if result.returncode != 0:
204+
print(f" WARNING: could not download windows runtime DLLs: {result.stderr}")
205+
return
206+
# Copy all DLLs to dest
207+
for dll in Path(tmp).rglob("*.dll"):
208+
shutil.copy2(dll, dest / dll.name)
209+
print(f" copied {dll.name} to libs/windows-x64/")
195210

196211
def trigger_and_wait_cache_build():
197212
"""Trigger a new build-cache CI run and wait for it to complete."""

0 commit comments

Comments
 (0)