Skip to content
Snippets Groups Projects
Commit 9bab6407 authored by Gregory Szorc's avatar Gregory Szorc
Browse files

tests: use venv on Python 3

This test was failing in some Python 3 environments because
`$PYTHON -m virtualenv` was somehow resulting in Python 2
being used. Why, I'm not sure.

Python 3 includes virtualenv in the standard library as the
`venv` module.

This commit changes test-install.t to use `$PYTHON -m venv` on
Python 3 and `$PYTHON -m virtualenv` on Python 2 (if available).

I chose to make some test output duplicated because we can't
have nested conditionals and there is no easy way to express
ORing of hghave checks.

Differential Revision: https://phab.mercurial-scm.org/D7224
parent 9a250055
No related branches found
No related tags found
No related merge requests found
...@@ -236,9 +236,7 @@ ...@@ -236,9 +236,7 @@
#endif #endif
#if virtualenv
Verify that Mercurial is installable with pip. Note that this MUST be Verify that Mercurial is installable with pip. Note that this MUST be
the last test in this file, because we do some nasty things to the the last test in this file, because we do some nasty things to the
shell environment in order to make the virtualenv work reliably. shell environment in order to make the virtualenv work reliably.
...@@ -241,5 +239,8 @@ ...@@ -241,5 +239,8 @@
Verify that Mercurial is installable with pip. Note that this MUST be Verify that Mercurial is installable with pip. Note that this MUST be
the last test in this file, because we do some nasty things to the the last test in this file, because we do some nasty things to the
shell environment in order to make the virtualenv work reliably. 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.
On Python 2, we use the 3rd party virtualenv module, if available.
$ cd $TESTTMP $ cd $TESTTMP
...@@ -245,4 +246,35 @@ ...@@ -245,4 +246,35 @@
$ cd $TESTTMP $ cd $TESTTMP
$ unset PYTHONPATH
#if py3
$ "$PYTHON" -m venv installenv >> pip.log
Note: we use this weird path to run pip and hg to avoid platform differences,
since it's bin on most platforms but Scripts on Windows.
$ ./installenv/*/pip install --no-index $TESTDIR/.. >> pip.log
$ ./installenv/*/hg debuginstall || cat pip.log
checking encoding (ascii)...
checking Python executable (*) (glob)
checking Python version (3.*) (glob)
checking Python lib (*)... (glob)
checking Python security support (*) (glob)
checking Mercurial version (*) (glob)
checking Mercurial custom build (*) (glob)
checking module policy (*) (glob)
checking installed modules (*/mercurial)... (glob)
checking registered compression engines (*) (glob)
checking available compression engines (*) (glob)
checking available compression engines for wire protocol (*) (glob)
checking "re2" regexp engine \((available|missing)\) (re)
checking templates ($TESTTMP/installenv/*/site-packages/mercurial/templates)... (glob)
checking default template ($TESTTMP/installenv/*/site-packages/mercurial/templates/map-cmdline.default) (glob)
checking commit editor... (*) (glob)
checking username (test)
no problems detected
#endif
#if no-py3 virtualenv
Note: --no-site-packages is deprecated, but some places have an Note: --no-site-packages is deprecated, but some places have an
ancient virtualenv from their linux distro or similar and it's not yet ancient virtualenv from their linux distro or similar and it's not yet
the default for them. the default for them.
...@@ -246,7 +278,7 @@ ...@@ -246,7 +278,7 @@
Note: --no-site-packages is deprecated, but some places have an Note: --no-site-packages is deprecated, but some places have an
ancient virtualenv from their linux distro or similar and it's not yet ancient virtualenv from their linux distro or similar and it's not yet
the default for them. the default for them.
$ unset PYTHONPATH
$ "$PYTHON" -m virtualenv --no-site-packages --never-download installenv >> pip.log $ "$PYTHON" -m virtualenv --no-site-packages --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. (?)
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 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 (?)
...@@ -250,6 +282,7 @@ ...@@ -250,6 +282,7 @@
$ "$PYTHON" -m virtualenv --no-site-packages --never-download installenv >> pip.log $ "$PYTHON" -m virtualenv --no-site-packages --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. (?)
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 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 (?)
Note: we use this weird path to run pip and hg to avoid platform differences, Note: we use this weird path to run pip and hg to avoid platform differences,
since it's bin on most platforms but Scripts on Windows. since it's bin on most platforms but Scripts on Windows.
$ ./installenv/*/pip install --no-index $TESTDIR/.. >> pip.log $ ./installenv/*/pip install --no-index $TESTDIR/.. >> pip.log
...@@ -258,8 +291,7 @@ ...@@ -258,8 +291,7 @@
$ ./installenv/*/hg debuginstall || cat pip.log $ ./installenv/*/hg debuginstall || cat pip.log
checking encoding (ascii)... checking encoding (ascii)...
checking Python executable (*) (glob) checking Python executable (*) (glob)
checking Python version (2.*) (glob) (no-py3 !) checking Python version (2.*) (glob)
checking Python version (3.*) (glob) (py3 !)
checking Python lib (*)... (glob) checking Python lib (*)... (glob)
checking Python security support (*) (glob) checking Python security support (*) (glob)
TLS 1.2 not supported by Python install; network connections lack modern security (?) TLS 1.2 not supported by Python install; network connections lack modern security (?)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment