File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 2
2
Initializer script that installs stuff to pip.
3
3
"""
4
4
5
+ from __future__ import annotations
6
+
5
7
import argparse
6
8
import logging
7
9
import os
10
+ import shutil
8
11
import subprocess
9
12
import sys
10
13
import time
11
- from typing import List
12
14
13
15
14
- def run_command (args : List [str ]) -> " subprocess.CompletedProcess[bytes]" :
16
+ def run_command (args : list [str ]) -> subprocess .CompletedProcess [bytes ]:
15
17
logging .debug ("$ %s" , " " .join (args ))
16
18
start_time = time .monotonic ()
17
19
try :
@@ -50,7 +52,17 @@ def run_command(args: List[str]) -> "subprocess.CompletedProcess[bytes]":
50
52
stream = sys .stderr ,
51
53
)
52
54
53
- pip_args = ["pip3" , "install" ]
55
+ uv_available = (
56
+ any (prefix in sys .base_prefix for prefix in ["uv/python" , "uv\\ python" ])
57
+ and shutil .which ("uv" ) is not None
58
+ )
59
+
60
+ if uv_available :
61
+ pip_args = ["uv" , "pip" , "install" ]
62
+ elif sys .executable :
63
+ pip_args = [sys .executable , "-mpip" , "install" ]
64
+ else :
65
+ pip_args = ["pip3" , "install" ]
54
66
55
67
# If we are in a global install, use `--user` to install so that you do not
56
68
# need root access in order to initialize linters.
You can’t perform that action at this time.
0 commit comments