MCPcopy
hub / github.com/httpie/cli / _discover_system_pip

Function _discover_system_pip

httpie/manager/compat.py:18–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16
17
18def _discover_system_pip() -> List[str]:
19 # When we are running inside of a frozen binary, we need the system
20 # pip to install plugins since there is no way for us to execute any
21 # code outside of the HTTPie.
22 #
23 # We explicitly depend on system pip, so the SystemError should not
24 # be executed (except for broken installations).
25 def _check_pip_version(pip_location: Optional[str]) -> bool:
26 if not pip_location:
27 return False
28
29 with suppress(subprocess.CalledProcessError):
30 stdout = subprocess.check_output([pip_location, "--version"], text=True)
31 return "python 3" in stdout
32
33 targets = [
34 "pip",
35 "pip3"
36 ]
37 for target in targets:
38 pip_location = shutil.which(target)
39 if _check_pip_version(pip_location):
40 return pip_location
41
42 raise SystemError("Couldn't find 'pip' executable. Please ensure that pip in your system is available.")
43
44
45def _run_pip_subprocess(pip_executable: List[str], args: List[str]) -> bytes:

Callers 1

run_pipFunction · 0.85

Calls 1

_check_pip_versionFunction · 0.85

Tested by

no test coverage detected