diff options
author | Benoit Pierre <benoit.pierre@gmail.com> | 2019-08-10 03:57:58 +0200 |
---|---|---|
committer | Benoit Pierre <benoit.pierre@gmail.com> | 2019-10-07 23:23:08 +0200 |
commit | 0d831c90e345ba6e7d0f82954f0cec5bdaa8501b (patch) | |
tree | 4693790688a9a8de6eed33aa410100eb200bd23d /tools | |
parent | 734d09c5a3f48338b6a3d7687c5f9d0ed02ab479 (diff) | |
download | python-setuptools-git-0d831c90e345ba6e7d0f82954f0cec5bdaa8501b.tar.gz |
improve workaround for #1644
Make it possible to use a more recent version of pip for tests.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tox_pip.py | 29 |
1 files changed, 29 insertions, 0 deletions
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:]) |