From 4a1f1a8482138cc64c83cb77b8e4276c654fe9ea Mon Sep 17 00:00:00 2001 From: xxyzz Date: Mon, 28 Feb 2022 11:25:35 +0800 Subject: [PATCH] Update Command Line Tool's pip if it's older then version 22 pip 21 is new enough to download the appropriate wheel file instead of build it from source, Apple provides 20 --- deps.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deps.py b/deps.py index 37840a9..1073e4e 100644 --- a/deps.py +++ b/deps.py @@ -105,8 +105,12 @@ def install_extra_deps(self): self.pip_install(pkg, value['version'], value['compiled']) def upgrade_mac_pip(self): + import re + r = subprocess.run([self.py, '-m', 'pip', '--version'], check=True, capture_output=True, text=True) - if r.stdout.startswith('pip 20'): - subprocess.run([self.py, '-m', 'pip', 'install', '-U', 'pip'], - check=True, capture_output=True, text=True) + m = re.match(r'pip (\d+)\.', r.stdout) + if m and int(m.group(1)) < 22: + subprocess.run( + [self.py, '-m', 'pip', 'install', '--user', '-U', 'pip'], + check=True, capture_output=True, text=True)