[PATCH] run-tests: avoid set PYTHONUSERBASE environment variable to None

Mihai Popescu mihai at unity3d.com
Mon Jan 8 13:23:13 UTC 2018


# HG changeset patch
# User Mihai Popescu <mihai at unity3d.com>
# Date 1515415963 -3600
#      Mon Jan 08 13:52:43 2018 +0100
# Node ID 913c426a392121e6f629f591374b8a10d55c05ea
# Parent  4c3a4bb31c0e3d9b8920b4c9b64ae930b1fe52ce
run-tests: avoid set PYTHONUSERBASE environment variable to None

According to python documentation, get_config_var can return None and it was
during running mercurial tests under a virtual environment with the local
built
mercurial installed as a python package with `pip install -e .`.

On the other hand, if mercurial is installed in the user library folders
with
`pip install --local -e .` the issue doesn't reproduce.

The fallback is that it will just set an empty string and everything should
work
as before, according to https://www.python.org/dev/peps/pep-0370/:

    The path to the user base directory can be overwritten with the
environment
    variable PYTHONUSERBASE. The default location is used when
PYTHONUSERBASE is
    not set or empty.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1037,7 +1037,7 @@
             offset = '' if i == 0 else '%s' % i
             env["HGPORT%s" % offset] = '%s' % (self._startport + i)
         env = os.environ.copy()
-        env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase')
+        env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
         env['HGEMITWARNINGS'] = '1'
         env['TESTTMP'] = self._testtmp
         env['HOME'] = self._testtmp



-- 
*Mihai Popescu*
Core Foundation Software Enginneer
Unity Technologies Copenhagen

<https://unity3d.com/?utm_source=email&utm_medium=signature&utm_campaign=engine_global_generalpromo_2017-02-Global-unity-brand&utm_content=Unity_email_general_platform_600x100>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180108/a3319cbe/attachment.html>


More information about the Mercurial-devel mailing list