# HG changeset patch # User Gregory Szorc # Date 2019-11-05 07:42:18 # Node ID ca0cd0a135141e1e4507f8f540a8bd3627089c59 # Parent a77338d2bdabb7aa81bb275b3794de7707843545 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 diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -829,6 +829,17 @@ def has_dev_full(): 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: 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 @@ the last test in this file, because we d 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,