Skip to content

Commit 7956986

Browse files
Merge pull request #1864 from benoit-pierre/improve_workaround_for_1644
improve workaround for #1644
2 parents 705d41e + 0d831c9 commit 7956986

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[pytest]
22
addopts=--doctest-modules --doctest-glob=pkg_resources/api_tests.txt -r sxX
3-
norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern .*
3+
norecursedirs=dist build *.egg setuptools/extern pkg_resources/extern tools .*
44
flake8-ignore =
55
setuptools/site-patch.py F821
66
setuptools/py*compat.py F811

tests/requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ coverage>=4.5.1
99
pytest-cov>=2.5.1
1010
paver; python_version>="3.6"
1111
futures; python_version=="2.7"
12-
pip==18.1 # Temporary workaround for #1644.

tools/tox_pip.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import shutil
3+
import subprocess
4+
import sys
5+
from glob import glob
6+
7+
VIRTUAL_ENV = os.environ['VIRTUAL_ENV']
8+
TOX_PIP_DIR = os.path.join(VIRTUAL_ENV, 'pip')
9+
10+
11+
def pip(args):
12+
# First things first, get a recent (stable) version of pip.
13+
if not os.path.exists(TOX_PIP_DIR):
14+
subprocess.check_call([sys.executable, '-m', 'pip',
15+
'--disable-pip-version-check',
16+
'install', '-t', TOX_PIP_DIR,
17+
'pip'])
18+
shutil.rmtree(glob(os.path.join(TOX_PIP_DIR, 'pip-*.dist-info'))[0])
19+
# And use that version.
20+
for n, a in enumerate(args):
21+
if not a.startswith('-'):
22+
if a in 'install' and '-e' in args[n:]:
23+
args.insert(n + 1, '--no-use-pep517')
24+
break
25+
subprocess.check_call([sys.executable, os.path.join(TOX_PIP_DIR, 'pip')] + args)
26+
27+
28+
if __name__ == '__main__':
29+
pip(sys.argv[1:])

tox.ini

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
[tox]
88
envlist=python
99

10+
[helpers]
11+
# Wrapper for calls to pip that make sure the version being used is a
12+
# up-to-date, and to prevent the current working directory from being
13+
# added to `sys.path`.
14+
pip = python {toxinidir}/tools/tox_pip.py
15+
1016
[testenv]
1117
deps=-rtests/requirements.txt
12-
# Changed from default (`python -m pip ...`)
13-
# to prevent the current working directory
14-
# from being added to `sys.path`.
15-
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}
16-
# Same as above.
17-
list_dependencies_command={envbindir}/pip freeze --all
18+
install_command = {[helpers]pip} install {opts} {packages}
19+
list_dependencies_command = {[helpers]pip} freeze --all
1820
setenv=COVERAGE_FILE={toxworkdir}/.coverage.{envname}
1921
# TODO: The passed environment variables came from copying other tox.ini files
2022
# These should probably be individually annotated to explain what needs them.

0 commit comments

Comments
 (0)