| 14 | |
| 15 | |
| 16 | def run_pex3( |
| 17 | *args, # type: Text |
| 18 | **kwargs # type: Any |
| 19 | ): |
| 20 | # type: (...) -> IntegResults |
| 21 | |
| 22 | python_exe = kwargs.pop("python", None) |
| 23 | if isinstance(python_exe, UvPython): |
| 24 | python = ensure_uv_python(python_exe) |
| 25 | elif python_exe: |
| 26 | python = python_exe |
| 27 | else: |
| 28 | python = sys.executable |
| 29 | |
| 30 | python = ( |
| 31 | installed_pex_wheel_venv_python(python) if kwargs.pop("use_pex_whl_venv", True) else python |
| 32 | ) |
| 33 | cmd = [python, "-mpex.cli"] + list(map(str, args)) |
| 34 | process = subprocess.Popen(args=cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) |
| 35 | stdout, stderr = process.communicate() |
| 36 | return IntegResults( |
| 37 | cmd=tuple(cmd), |
| 38 | output=stdout.decode("utf-8"), |
| 39 | error=stderr.decode("utf-8"), |
| 40 | return_code=process.returncode, |
| 41 | ) |