changeset 30429:270b077d434b

run-tests: forward Python USER_BASE from site (issue5425) We do this so that any linters installed via pip install --user don't break. See https://docs.python.org/2/library/site.html#site.USER_BASE for a description of what this nonsense is all about. An alternative would be to not set HOME, but that'll cause other problems (see issue2707), or to forward every single path entry from sys.path in PYTHONPATH (which seems sketchy in its own way).
author Augie Fackler <augie@google.com>
date Thu, 10 Nov 2016 16:07:24 -0500
parents 1156ec81f709
children 21772a6a7861
files tests/run-tests.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Tue Nov 15 20:25:51 2016 +0000
+++ b/tests/run-tests.py	Thu Nov 10 16:07:24 2016 -0500
@@ -58,6 +58,11 @@
 import socket
 import subprocess
 import sys
+try:
+    import sysconfig
+except ImportError:
+    # sysconfig doesn't exist in Python 2.6
+    sysconfig = None
 import tempfile
 import threading
 import time
@@ -818,6 +823,8 @@
             offset = '' if i == 0 else '%s' % i
             env["HGPORT%s" % offset] = '%s' % (self._startport + i)
         env = os.environ.copy()
+        if sysconfig is not None:
+            env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase')
         env['TESTTMP'] = self._testtmp
         env['HOME'] = self._testtmp
         # This number should match portneeded in _getport