setup.py
changeset 52661 958d5c998505
parent 52640 24ee91ba9aa8
child 52662 e5aadff6cb7d
--- 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