Patchwork D7228: tests: look for ensurepip before using venv

login
register
mail settings
Submitter phabricator
Date Nov. 5, 2019, 4:04 p.m.
Message ID <96cd8472f0e319fac534ff11324d05e4@localhost.localdomain>
Download mbox | patch
Permalink /patch/42751/
State Not Applicable
Headers show

Comments

phabricator - Nov. 5, 2019, 4:04 p.m.
Closed by commit rHGca0cd0a13514: tests: look for ensurepip before using venv (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7228?vs=17551&id=17553

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7228/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7228

AFFECTED FILES
  tests/hghave.py
  tests/test-install.t

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mjpieters, mercurial-devel

Patch

diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -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,
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -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: