|
28 | 28 | "-Csetup-args=-Dfont=disabled",
|
29 | 29 | ]
|
30 | 30 |
|
| 31 | +# We assume this script works with any pip version above this. |
| 32 | +PIP_MIN_VERSION = "23.1" |
| 33 | + |
31 | 34 |
|
32 | 35 | class Colors(Enum):
|
33 | 36 | RESET = "\033[0m"
|
@@ -162,6 +165,16 @@ def show_diff_and_suggest_fix(parent: str):
|
162 | 165 | raise
|
163 | 166 |
|
164 | 167 |
|
| 168 | +def check_version_atleast(version: str, min_version: str): |
| 169 | + try: |
| 170 | + version_tup = tuple(int(i.strip()) for i in version.split(".")) |
| 171 | + min_version_tup = tuple(int(i.strip()) for i in min_version.split(".")) |
| 172 | + except (AttributeError, TypeError, ValueError): |
| 173 | + return False |
| 174 | + |
| 175 | + return version_tup >= min_version_tup |
| 176 | + |
| 177 | + |
165 | 178 | class Dev:
|
166 | 179 | def __init__(self) -> None:
|
167 | 180 | self.py: Path = Path(sys.executable)
|
@@ -358,8 +371,17 @@ def prep_env(self):
|
358 | 371 | else:
|
359 | 372 | pprint(f"Using python '{self.py}'")
|
360 | 373 |
|
361 |
| - pprint("Upgrading pip") |
362 |
| - pip_install(self.py, ["-U", "pip"]) |
| 374 | + pprint("Checking pip version") |
| 375 | + pip_v = cmd_run([self.py, "-m", "pip", "-V"], capture_output=True) |
| 376 | + try: |
| 377 | + pip_version = pip_v.split()[1] |
| 378 | + except (AttributeError, IndexError): |
| 379 | + pip_version = "UNKNOWN" |
| 380 | + |
| 381 | + pprint(f"Determined pip version: {pip_version}") |
| 382 | + if not check_version_atleast(pip_version, PIP_MIN_VERSION): |
| 383 | + pprint("pip version is too old or unknown, attempting pip upgrade") |
| 384 | + pip_install(self.py, ["-U", "pip"]) |
363 | 385 |
|
364 | 386 | deps = self.deps.get(self.args["command"])
|
365 | 387 | if deps:
|
|
0 commit comments