From 3592dba3388c7a0d104aeab33e6f4b7b45e03341 Mon Sep 17 00:00:00 2001 From: hamdanal <93259987+hamdanal@users.noreply.github.com> Date: Sun, 18 Dec 2022 13:05:31 +0100 Subject: [PATCH] Stubtest_third_party.py: better error message if ensurepip isn't available --- tests/stubtest_third_party.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 61ba07e71..d9b612396 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -43,7 +43,16 @@ def run_stubtest(dist: Path, *, verbose: bool = False, specified_stubs_only: boo with tempfile.TemporaryDirectory() as tmp: venv_dir = Path(tmp) - venv.create(venv_dir, with_pip=True, clear=True) + try: + venv.create(venv_dir, with_pip=True, clear=True) + except subprocess.CalledProcessError as e: + if "ensurepip" in e.cmd: + print_error("fail") + print_error( + "stubtest requires a Python installation with ensurepip. " + "If on Linux, you may need to install the python3-venv package." + ) + raise if sys.platform == "win32": pip = venv_dir / "Scripts" / "pip.exe"