Skip to content

Commit 743fd55

Browse files
paugierfrostming
andauthored
fix: env for calling Python applications (#295)
Co-authored-by: Frost Ming <me@frostming.com>
1 parent 075cc25 commit 743fd55

File tree

1 file changed

+8
-0
lines changed
  • src/pdm/backend/hooks/version

1 file changed

+8
-0
lines changed

src/pdm/backend/hooks/version/scm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ def _subprocess_call(
4646
if not k.startswith("GIT_")
4747
or k in ("GIT_EXEC_PATH", "GIT_SSH", "GIT_SSH_COMMAND")
4848
}
49+
# adapted from setuptools-scm
50+
# PYTHONPATH can break Python applications installed with Pipx, UV, etc.
51+
if "PYTHONPATH" in env:
52+
env["PYTHONPATH"] = os.pathsep.join(
53+
path
54+
for path in env["PYTHONPATH"].split(os.pathsep)
55+
if "-build-env-" not in path
56+
)
4957
env.update({"LC_ALL": "C", "LANG": "", "HGPLAIN": "1"})
5058
if extra_env:
5159
env.update(extra_env)

0 commit comments

Comments
 (0)