aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2019-08-10 03:57:58 +0200
committerBenoit Pierre <benoit.pierre@gmail.com>2019-10-07 23:23:08 +0200
commit0d831c90e345ba6e7d0f82954f0cec5bdaa8501b (patch)
tree4693790688a9a8de6eed33aa410100eb200bd23d
parent734d09c5a3f48338b6a3d7687c5f9d0ed02ab479 (diff)
downloadexternal_python_setuptools-0d831c90e345ba6e7d0f82954f0cec5bdaa8501b.tar.gz
external_python_setuptools-0d831c90e345ba6e7d0f82954f0cec5bdaa8501b.tar.bz2
external_python_setuptools-0d831c90e345ba6e7d0f82954f0cec5bdaa8501b.zip
improve workaround for #1644
Make it possible to use a more recent version of pip for tests.
-rw-r--r--pytest.ini2
-rw-r--r--tests/requirements.txt1
-rw-r--r--tools/tox_pip.py29
-rw-r--r--tox.ini14
4 files changed, 38 insertions, 8 deletions
diff --git a/pytest.ini b/pytest.ini
index 612fb91f..764a55dd 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,6 +1,6 @@
[pytest]
addopts=--doctest-modules --doctest-glob=pkg_resources/api_tests.txt -r sxX
-norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern .*
+norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern tools .*
flake8-ignore =
setuptools/site-patch.py F821
setuptools/py*compat.py F811
diff --git a/tests/requirements.txt b/tests/requirements.txt
index cb3e6726..1f70adee 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -9,4 +9,3 @@ coverage>=4.5.1
pytest-cov>=2.5.1
paver; python_version>="3.6"
futures; python_version=="2.7"
-pip==18.1 # Temporary workaround for #1644.
diff --git a/tools/tox_pip.py b/tools/tox_pip.py
new file mode 100644
index 00000000..1117f996
--- /dev/null
+++ b/tools/tox_pip.py
@@ -0,0 +1,29 @@
+import os
+import shutil
+import subprocess
+import sys
+from glob import glob
+
+VIRTUAL_ENV = os.environ['VIRTUAL_ENV']
+TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, 'pip')
+
+
+def pip(args):
+ # First things first, get a recent (stable) version of pip.
+ if not os.path.exists(TOX_PIP_DIR):
+ subprocess.check_call([sys.executable, '-m', 'pip',
+ '--disable-pip-version-check',
+ 'install', '-t', TOX_PIP_DIR,
+ 'pip'])
+ shutil.rmtree(glob(os.path.join(TOX_PIP_DIR, 'pip-*.dist-info'))[0])
+ # And use that version.
+ for n, a in enumerate(args):
+ if not a.startswith('-'):
+ if a in 'install' and '-e' in args[n:]:
+ args.insert(n + 1, '--no-use-pep517')
+ break
+ subprocess.check_call([sys.executable, os.path.join(TOX_PIP_DIR, 'pip')] + args)
+
+
+if __name__ == '__main__':
+ pip(sys.argv[1:])
diff --git a/tox.ini b/tox.ini
index e0eef95a..8b34c235 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,14 +7,16 @@
[tox]
envlist=python
+[helpers]
+# Wrapper for calls to pip that make sure the version being used is a
+# up-to-date, and to prevent the current working directory from being
+# added to `sys.path`.
+pip = python {toxinidir}/tools/tox_pip.py
+
[testenv]
deps=-rtests/requirements.txt
-# Changed from default (`python -m pip ...`)
-# to prevent the current working directory
-# from being added to `sys.path`.
-install_command=python -c 'import sys; sys.path.remove(""); from pkg_resources import load_entry_point; load_entry_point("pip", "console_scripts", "pip")()' install {opts} {packages}
-# Same as above.
-list_dependencies_command={envbindir}/pip freeze --all
+install_command = {[helpers]pip} install {opts} {packages}
+list_dependencies_command = {[helpers]pip} freeze --all
setenv=COVERAGE_FILE={toxworkdir}/.coverage.{envname}
# TODO: The passed environment variables came from copying other tox.ini files
# These should probably be individually annotated to explain what needs them.