Skip to content

Commit 08e02f4

Browse files
committed
Generalise pip_install for newer pip versions
1 parent 63b000f commit 08e02f4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/get-pip-template.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ def pip_extract(pkgname, dest=None):
6262

6363
def pip_install(pkgname, *args):
6464

65+
import sys
66+
import subprocess
6567
import pip
66-
rc = pip.main(["install"] + [pkgname] + list(args))
68+
69+
pip_main = lambda *a: pip.main(list(a))
70+
if hasattr(pip, "_internal"):
71+
pip_call = [sys.executable, "-m", "pip"]
72+
pip_main = lambda *a: subprocess.call(pip_call + list(a))
73+
74+
rc = pip_main("install", pkgname, *args)
6775
if rc != 0:
6876
raise RuntimeError("pip failed with exit code {0}".format(rc))
6977

0 commit comments

Comments
 (0)