Skip to content

Commit 3fc28ae

Browse files
committed
Re-work environment markers lock for Windows.
1 parent 709b98a commit 3fc28ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dev_cmd/venv.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def marker_environment(python: str) -> dict[str, str]:
101101
fingerprint = _fingerprint(python.encode())
102102
markers_file = _ensure_cache_dir() / "interpreters" / f"markers.{fingerprint}.json"
103103
if not os.path.exists(markers_file):
104-
with FileLock(markers_file), TemporaryDirectory(
104+
with FileLock(f"{markers_file}.lck"), TemporaryDirectory(
105105
dir=markers_file.parent, prefix="packaging-venv."
106106
) as td:
107107
print(
@@ -114,7 +114,8 @@ def marker_environment(python: str) -> dict[str, str]:
114114
stdout=sys.stderr.fileno(),
115115
check=True,
116116
)
117-
markers_file.write_bytes(
117+
temp_markers_file = Path(td) / markers_file.name
118+
temp_markers_file.write_bytes(
118119
subprocess.run(
119120
args=[
120121
venv_layout.python,
@@ -134,6 +135,7 @@ def marker_environment(python: str) -> dict[str, str]:
134135
check=True,
135136
).stdout
136137
)
138+
temp_markers_file.rename(markers_file)
137139
return cast(Dict[str, str], json.loads(markers_file.read_bytes()))
138140

139141

0 commit comments

Comments
 (0)