[Request] [+- ] D9547: hghave: update the check for virtualenv

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Wed Dec 9 04:38:59 UTC 2020


mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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 <https://phab.mercurial-scm.org/rHG357d8415aa27b5366799adbb93896f0c592dffe8> 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 <https://phab.mercurial-scm.org/rHG357d8415aa27b5366799adbb93896f0c592dffe8> 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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

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 @@
   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 @@
   $ ./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)
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -886,17 +886,16 @@
         return False
 
 
- at check("py2virtualenv", "Python2 virtualenv support")
-def has_py2virtualenv():
-    if sys.version_info[0] != 2:
-        return False
-
+ at 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
 
 



To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20201209/b47a3199/attachment-0001.html>


More information about the Mercurial-patches mailing list