# HG changeset patch # User Matt Harbison # Date 2020-12-08 17:43:18 # Node ID 1b5e0d0bdb05d724abbf049fcbca00ba6e905208 # Parent 4d5e2fd53707527129c353bb8eaa1246c6f7f1da hghave: update the check for virtualenv This started as `hghave --test-features` failing on Windows in `test-hghave.t`. IDK how this worked, as neither my Linux nor Windows machines have the old attribute with virtualenv 20.2.2, even on py2. I think this was noticed recently because 357d8415aa27 mentioned an AttributeError, and mitigated by making this py2 only. But as mentioned, this is also a problem on py2 (where the failure was observed). When I got this working by removing the attribute reference, the command in the test failed because the `--no-site-package` argument was removed some time ago. Therefore, this backs out 357d8415aa27 and references a known good attribute (which was done to suppress the warning about an unused import) that also ensures the command does not need the argument. Since there appears to be (minor) broken stuff on py3, manually apply the `no-py3` guard that was backed out of the check itself. Differential Revision: https://phab.mercurial-scm.org/D9547 diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -886,17 +886,16 @@ def has_ensurepip(): return False -@check("py2virtualenv", "Python2 virtualenv support") -def has_py2virtualenv(): - if sys.version_info[0] != 2: - return False - +@check("virtualenv", "virtualenv support") +def has_virtualenv(): try: import virtualenv - virtualenv.ACTIVATE_SH - return True - except ImportError: + # --no-site-package became the default in 1.7 (Nov 2011), and the + # argument was removed in 20.0 (Feb 2020). Rather than make the + # script complicated, just ignore ancient versions. + return int(virtualenv.__version__.split('.')[0]) > 1 + except (AttributeError, ImportError, IndexError): return False diff --git a/tests/test-install.t b/tests/test-install.t --- a/tests/test-install.t +++ b/tests/test-install.t @@ -222,13 +222,11 @@ since it's bin on most platforms but Scr no problems detected #endif -#if py2virtualenv +#if virtualenv no-py3 -Note: --no-site-packages is deprecated, but some places have an -ancient virtualenv from their linux distro or similar and it's not yet -the default for them. +Note: --no-site-packages is the default for all versions enabled by hghave - $ "$PYTHON" -m virtualenv --no-site-packages --never-download installenv >> pip.log + $ "$PYTHON" -m virtualenv --never-download installenv >> pip.log DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. (?) DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support (?) @@ -237,6 +235,7 @@ since it's bin on most platforms but Scr $ ./installenv/*/pip install --no-index $TESTDIR/.. >> pip.log DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. (?) DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support (?) + DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. (?) $ ./installenv/*/hg debuginstall || cat pip.log checking encoding (ascii)... checking Python executable (*) (glob)