summaryrefslogtreecommitdiff
path: root/tools/tox_pip.py
diff options
context:
space:
mode:
authorBenoit Pierre <benoit.pierre@gmail.com>2019-11-13 10:20:49 +0000
committerGitHub <noreply@github.com>2019-11-13 10:20:49 +0000
commit7956986ed1b9da63624b321d81f6c1bfbf360730 (patch)
tree6f6331f999b8ad43c5685268e92774ceabb34f00 /tools/tox_pip.py
parent705d41e4903bc2d12a805172c0f446e2eb32eb9c (diff)
parent0d831c90e345ba6e7d0f82954f0cec5bdaa8501b (diff)
downloadpython-setuptools-git-7956986ed1b9da63624b321d81f6c1bfbf360730.tar.gz
Merge pull request #1864 from benoit-pierre/improve_workaround_for_1644
improve workaround for #1644
Diffstat (limited to 'tools/tox_pip.py')
-rw-r--r--tools/tox_pip.py29
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:])