tests: look for ensurepip before using venv stable
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 04 Nov 2019 23:42:18 -0800
branchstable
changeset 43412 ca0cd0a13514
parent 43411 a77338d2bdab
child 43413 acdd4f28f6a3
tests: look for ensurepip before using venv Debian appears to cripple the venv module by default by removing the associated ensurepip functionality. (The module isn't present at all.) This caused test-install.t to fail when using the Debian python3 unless the python3-venv package was installed. This commit introduces a new hghave requirement for detecting ensurepip and makes the Python 3 install variant conditional on its presence. This should make test-install.t pass when using an incomplete Debian Python. Differential Revision: https://phab.mercurial-scm.org/D7228
tests/hghave.py
tests/test-install.t
--- a/tests/hghave.py	Thu Oct 17 16:46:13 2019 -0400
+++ b/tests/hghave.py	Mon Nov 04 23:42:18 2019 -0800
@@ -829,6 +829,17 @@
     return os.path.exists('/dev/full')
 
 
+@check("ensurepip", "ensurepip module")
+def has_ensurepip():
+    try:
+        import ensurepip
+
+        ensurepip.bootstrap
+        return True
+    except ImportError:
+        return False
+
+
 @check("virtualenv", "Python virtualenv support")
 def has_virtualenv():
     try:
--- a/tests/test-install.t	Thu Oct 17 16:46:13 2019 -0400
+++ b/tests/test-install.t	Mon Nov 04 23:42:18 2019 -0800
@@ -241,12 +241,15 @@
 shell environment in order to make the virtualenv work reliably.
 
 On Python 3, we use the venv module, which is part of the standard library.
+But some Linux distros strip out this module's functionality involving pip,
+so we have to look for the ensurepip module, which these distros strip out
+completely.
 On Python 2, we use the 3rd party virtualenv module, if available.
 
   $ cd $TESTTMP
   $ unset PYTHONPATH
 
-#if py3
+#if py3 ensurepip
   $ "$PYTHON" -m venv installenv >> pip.log
 
 Note: we use this weird path to run pip and hg to avoid platform differences,