changeset 52686:958d5c998505

setup-py: weaken build isolation when calling hg See https://github.com/pypa/setuptools-scm/blob/5d3a1f88382c7106d009a0731df97330e4cf5f7c/src/setuptools_scm/_run_cmd.py#L105
author paugier <pierre.augier@univ-grenoble-alpes.fr>
date Wed, 04 Dec 2024 22:52:58 +0100
parents 1c8bc6110a1a
children e5aadff6cb7d
files setup.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Sat Jan 04 11:13:15 2025 -0500
+++ b/setup.py	Wed Dec 04 22:52:58 2024 +0100
@@ -242,6 +242,16 @@
     # and disable localization for the same reasons.
     hgenv['HGPLAIN'] = '1'
     hgenv['LANGUAGE'] = 'C'
+    # PYTHONPATH and co can be used for isolated builds, which can break hg
+    hgenv.pop("PYTHONNOUSERSITE", None)
+    if "PYTHONPATH" in hgenv:
+        hgenv["PYTHONPATH"] = os.pathsep.join(
+            [
+                path
+                for path in hgenv["PYTHONPATH"].split(os.pathsep)
+                if "-build-env-" not in path
+            ]
+        )
     hgcmd = ['hg']
     # Run a simple "hg log" command just to see if using hg from the user's
     # path works and can successfully interact with this repository.  Windows