()
| 16 | |
| 17 | |
| 18 | def _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 | |
| 45 | def _run_pip_subprocess(pip_executable: List[str], args: List[str]) -> bytes: |
no test coverage detected