[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/51] Revert "mkvenv: work around broken pip installations on Deb
From: |
Paolo Bonzini |
Subject: |
[PULL 36/51] Revert "mkvenv: work around broken pip installations on Debian 10" |
Date: |
Thu, 7 Sep 2023 14:59:45 +0200 |
Debian 10 has Python 3.7, so it is not possible to use it anymore
now that Python 3.8 is required.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
python/scripts/mkvenv.py | 74 +++++++++-------------------------------
1 file changed, 16 insertions(+), 58 deletions(-)
diff --git a/python/scripts/mkvenv.py b/python/scripts/mkvenv.py
index 6797e12e349..d0b9c215ca2 100644
--- a/python/scripts/mkvenv.py
+++ b/python/scripts/mkvenv.py
@@ -61,8 +61,6 @@
"""
-# pylint: disable=too-many-lines
-
# Copyright (C) 2022-2023 Red Hat, Inc.
#
# Authors:
@@ -195,7 +193,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
):
kwargs["with_pip"] = False
else:
- check_ensurepip(suggest_remedy=True)
+ check_ensurepip()
super().__init__(*args, **kwargs)
@@ -300,7 +298,7 @@ def need_ensurepip() -> bool:
return True
-def check_ensurepip(prefix: str = "", suggest_remedy: bool = False) -> None:
+def check_ensurepip() -> None:
"""
Check that we have ensurepip.
@@ -311,15 +309,12 @@ def check_ensurepip(prefix: str = "", suggest_remedy:
bool = False) -> None:
"Python's ensurepip module is not found.\n"
"It's normally part of the Python standard library, "
"maybe your distribution packages it separately?\n"
- "(Debian puts ensurepip in its python3-venv package.)\n"
+ "Either install ensurepip, or alleviate the need for it in the "
+ "first place by installing pip and setuptools for "
+ f"'{sys.executable}'.\n"
+ "(Hint: Debian puts ensurepip in its python3-venv package.)"
)
- if suggest_remedy:
- msg += (
- "Either install ensurepip, or alleviate the need for it in the"
- " first place by installing pip and setuptools for "
- f"'{sys.executable}'.\n"
- )
- raise Ouch(prefix + msg)
+ raise Ouch(msg)
# ensurepip uses pyexpat, which can also go missing on us:
if not find_spec("pyexpat"):
@@ -327,15 +322,12 @@ def check_ensurepip(prefix: str = "", suggest_remedy:
bool = False) -> None:
"Python's pyexpat module is not found.\n"
"It's normally part of the Python standard library, "
"maybe your distribution packages it separately?\n"
- "(NetBSD's pkgsrc debundles this to e.g. 'py310-expat'.)\n"
+ "Either install pyexpat, or alleviate the need for it in the "
+ "first place by installing pip and setuptools for "
+ f"'{sys.executable}'.\n\n"
+ "(Hint: NetBSD's pkgsrc debundles this to e.g. 'py310-expat'.)"
)
- if suggest_remedy:
- msg += (
- "Either install pyexpat, or alleviate the need for it in the "
- "first place by installing pip and setuptools for "
- f"'{sys.executable}'.\n"
- )
- raise Ouch(prefix + msg)
+ raise Ouch(msg)
def make_venv( # pylint: disable=too-many-arguments
@@ -489,38 +481,6 @@ def generate_console_scripts(
logger.debug("wrote console_script '%s'", filename)
-def checkpip() -> bool:
- """
- Debian10 has a pip that's broken when used inside of a virtual environment.
-
- We try to detect and correct that case here.
- """
- try:
- # pylint: disable=import-outside-toplevel,unused-import,import-error
- # pylint: disable=redefined-outer-name
- import pip._internal # type: ignore # noqa: F401
-
- logger.debug("pip appears to be working correctly.")
- return False
- except ModuleNotFoundError as exc:
- if exc.name == "pip._internal":
- # Uh, fair enough. They did say "internal".
- # Let's just assume it's fine.
- return False
- logger.warning("pip appears to be malfunctioning: %s", str(exc))
-
- check_ensurepip("pip appears to be non-functional, and ")
-
- logger.debug("Attempting to repair pip ...")
- subprocess.run(
- (sys.executable, "-m", "ensurepip"),
- stdout=subprocess.DEVNULL,
- check=True,
- )
- logger.debug("Pip is now (hopefully) repaired!")
- return True
-
-
def pkgname_from_depspec(dep_spec: str) -> str:
"""
Parse package name out of a PEP-508 depspec.
@@ -877,12 +837,10 @@ def post_venv_setup() -> None:
This is intended to be run *inside the venv* after it is created.
"""
logger.debug("post_venv_setup()")
- # Test for a broken pip (Debian 10 or derivative?) and fix it if needed
- if not checkpip():
- # Finally, generate a 'pip' script so the venv is usable in a normal
- # way from the CLI. This only happens when we inherited pip from a
- # parent/system-site and haven't run ensurepip in some way.
- generate_console_scripts(["pip"])
+ # Generate a 'pip' script so the venv is usable in a normal
+ # way from the CLI. This only happens when we inherited pip from a
+ # parent/system-site and haven't run ensurepip in some way.
+ generate_console_scripts(["pip"])
def _add_create_subcommand(subparsers: Any) -> None:
--
2.41.0
- [PULL 30/51] configure, meson: remove CONFIG_SOLARIS from config-host.mak, (continued)
- [PULL 30/51] configure, meson: remove CONFIG_SOLARIS from config-host.mak, Paolo Bonzini, 2023/09/07
- [PULL 32/51] meson: list leftover CONFIG_* symbols, Paolo Bonzini, 2023/09/07
- [PULL 29/51] configure, meson: move --enable-plugins to meson, Paolo Bonzini, 2023/09/07
- [PULL 31/51] configure, meson: remove target OS symbols from config-host.mak, Paolo Bonzini, 2023/09/07
- [PULL 35/51] mkvenv: assume presence of importlib.metadata, Paolo Bonzini, 2023/09/07
- [PULL 34/51] Python: Drop support for Python 3.7, Paolo Bonzini, 2023/09/07
- [PULL 33/51] configure: remove dead code, Paolo Bonzini, 2023/09/07
- [PULL 39/51] hw/i386/fw_cfg: Include missing 'cpu.h' header, Paolo Bonzini, 2023/09/07
- [PULL 38/51] hw/i386/pc: Include missing 'cpu.h' header, Paolo Bonzini, 2023/09/07
- [PULL 28/51] configure: unify recursion into sub-Makefiles, Paolo Bonzini, 2023/09/07
- [PULL 36/51] Revert "mkvenv: work around broken pip installations on Debian 10",
Paolo Bonzini <=
- [PULL 37/51] hw/i386/pc: Include missing 'sysemu/tcg.h' header, Paolo Bonzini, 2023/09/07
- [PULL 41/51] target/i386/cpu-sysemu: Inline kvm_apic_in_kernel(), Paolo Bonzini, 2023/09/07
- [PULL 40/51] target/i386/helper: Restrict KVM declarations to system emulation, Paolo Bonzini, 2023/09/07
- [PULL 46/51] sysemu/kvm: Restrict kvm_arch_get_supported_cpuid/msr() to x86 targets, Paolo Bonzini, 2023/09/07
- [PULL 48/51] sysemu/kvm: Restrict kvm_has_pit_state2() to x86 targets, Paolo Bonzini, 2023/09/07
- [PULL 47/51] sysemu/kvm: Restrict kvm_get_apic_state() to x86 targets, Paolo Bonzini, 2023/09/07
- [PULL 42/51] target/i386: Remove unused KVM stubs, Paolo Bonzini, 2023/09/07
- [PULL 44/51] target/i386: Allow elision of kvm_hv_vpindex_settable(), Paolo Bonzini, 2023/09/07
- [PULL 51/51] docs/system/replay: do not show removed command line option, Paolo Bonzini, 2023/09/07
- [PULL 49/51] sysemu/kvm: Restrict kvm_pc_setup_irq_routing() to x86 targets, Paolo Bonzini, 2023/09/07