Skip to content

Commit 9ca868a

Browse files
authored
Fixes temporary file issue on Windows (#211)
On Windows we cannot reopen a temp file so we get permission denied errors in this code. This PR resolves this issue.
1 parent 8921a43 commit 9ca868a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pyodide_build/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from contextlib import contextmanager
1919
from functools import cache
2020
from pathlib import Path
21-
from tempfile import NamedTemporaryFile, TemporaryDirectory
21+
from tempfile import TemporaryDirectory
2222
from typing import Any, NoReturn
2323
from urllib.request import urlopen
2424
from zipfile import ZipFile
@@ -619,8 +619,8 @@ def download_and_unpack_archive(
619619
# f"Failed to download cross-build environment from {url} (status code: {r.status_code})"
620620
# )
621621

622-
with NamedTemporaryFile(suffix=".tar") as f:
623-
f_path = Path(f.name)
622+
with TemporaryDirectory() as temp_dir:
623+
f_path = Path(temp_dir) / "temp.tar"
624624
f_path.write_bytes(data)
625625
with warnings.catch_warnings():
626626
# Python 3.12-3.13 emits a DeprecationWarning when using shutil.unpack_archive without a filter,

0 commit comments

Comments
 (0)