Skip to content

Commit 4badd79

Browse files
committed
fix: env for calling Python applications
1 parent 3000087 commit 4badd79

File tree

1 file changed

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

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ 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+
[
54+
path
55+
for path in env["PYTHONPATH"].split(os.pathsep)
56+
if "-build-env-" not in path
57+
]
58+
)
4959
env.update({"LC_ALL": "C", "LANG": "", "HGPLAIN": "1"})
5060
if extra_env:
5161
env.update(extra_env)

0 commit comments

Comments
 (0)