Skip to content

Commit

Permalink
build.make-venv: avoid using pathlib.Path("foo").exists with follow_s…
Browse files Browse the repository at this point in the history
…ymlinks

It's apparently a Python 3.12+ thing
  • Loading branch information
adisbladis committed Nov 14, 2024
1 parent 408ab41 commit 49253cc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions build/hooks/make-venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
import typing
from pathlib import Path
from textwrap import dedent
from venv import EnvBuilder

EXECUTABLE = os.path.basename(sys.executable)
Expand Down Expand Up @@ -182,11 +181,14 @@ def _link(input: Path, out: Path) -> None:
st_mode = input.lstat().st_mode

if stat.S_ISDIR(st_mode):
if out.exists(follow_symlinks=False):
try:
out.lstat()
except FileNotFoundError:
out.mkdir()
else:
if out.is_symlink():
_upgrade_existing_dir(input, out)
else:
out.mkdir()

for filename in os.listdir(input):
_link(input.joinpath(filename), out.joinpath(filename))

Expand Down

0 comments on commit 49253cc

Please sign in to comment.