From a826a2ba215fa2649188e9e90ab0f99873bce188 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 21 Jan 2024 23:36:52 +0000 Subject: [PATCH] drop support for pip 19.0.0 --- src/poetry/installation/executor.py | 16 ++-------------- src/poetry/utils/env/base_env.py | 11 ----------- src/poetry/utils/env/mock_env.py | 8 -------- src/poetry/utils/env/system_env.py | 6 ------ src/poetry/utils/env/virtual_env.py | 11 ----------- tests/utils/env/test_env.py | 6 +++--- 6 files changed, 5 insertions(+), 53 deletions(-) diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py index 4bd7604872e..2962e7716dc 100644 --- a/src/poetry/installation/executor.py +++ b/src/poetry/installation/executor.py @@ -696,15 +696,6 @@ def _install_directory_without_wheel_installer( package_poetry = Factory().create_poetry(pyproject.file.path.parent) if package_poetry is not None: - # Even if there is a build system specified - # some versions of pip (< 19.0.0) don't understand it - # so we need to check the version of pip to know - # if we can rely on the build system - legacy_pip = ( - self._env.pip_version - < self._env.pip_version.__class__.from_parts(19, 0, 0) - ) - builder: Builder if package.develop and not package_poetry.package.build_script: from poetry.masonry.builders.editable import EditableBuilder @@ -716,13 +707,10 @@ def _install_directory_without_wheel_installer( builder.build() return 0 - elif legacy_pip or package_poetry.package.build_script: + + if package_poetry.package.build_script: from poetry.core.masonry.builders.sdist import SdistBuilder - # We need to rely on creating a temporary setup.py - # file since the version of pip does not support - # build-systems - # We also need it for non-PEP-517 packages builder = SdistBuilder(package_poetry) with builder.setup_py(): return self.pip_install(req, upgrade=True, editable=package.develop) diff --git a/src/poetry/utils/env/base_env.py b/src/poetry/utils/env/base_env.py index 0880502cf41..f3e4785f789 100644 --- a/src/poetry/utils/env/base_env.py +++ b/src/poetry/utils/env/base_env.py @@ -54,7 +54,6 @@ def __init__(self, path: Path, base: Path | None = None) -> None: self._base = base or path self._marker_env: dict[str, Any] | None = None - self._pip_version: Version | None = None self._site_packages: SitePackages | None = None self._paths: dict[str, str] | None = None self._supported_tags: list[Tag] | None = None @@ -170,13 +169,6 @@ def platform(self) -> str: def os(self) -> str: return os.name - @property - def pip_version(self) -> Version: - if self._pip_version is None: - self._pip_version = self.get_pip_version() - - return self._pip_version - @property def site_packages(self) -> SitePackages: if self._site_packages is None: @@ -288,9 +280,6 @@ def get_pip_command(self, embedded: bool = False) -> list[str]: def get_supported_tags(self) -> list[Tag]: raise NotImplementedError() - def get_pip_version(self) -> Version: - raise NotImplementedError() - def get_paths(self) -> dict[str, str]: raise NotImplementedError() diff --git a/src/poetry/utils/env/mock_env.py b/src/poetry/utils/env/mock_env.py index 225b88f69be..59fb37bc49b 100644 --- a/src/poetry/utils/env/mock_env.py +++ b/src/poetry/utils/env/mock_env.py @@ -3,8 +3,6 @@ from typing import TYPE_CHECKING from typing import Any -from poetry.core.constraints.version import Version - from poetry.utils.env.null_env import NullEnv @@ -22,7 +20,6 @@ def __init__( platform_machine: str = "amd64", os_name: str = "posix", is_venv: bool = False, - pip_version: str = "19.1", sys_path: list[str] | None = None, marker_env: dict[str, Any] | None = None, supported_tags: list[Tag] | None = None, @@ -36,7 +33,6 @@ def __init__( self._platform_machine = platform_machine self._os_name = os_name self._is_venv = is_venv - self._pip_version: Version = Version.parse(pip_version) self._sys_path = sys_path self._mock_marker_env = marker_env self._supported_tags = supported_tags @@ -53,10 +49,6 @@ def platform_machine(self) -> str: def os(self) -> str: return self._os_name - @property - def pip_version(self) -> Version: - return self._pip_version - @property def sys_path(self) -> list[str]: if self._sys_path is None: diff --git a/src/poetry/utils/env/system_env.py b/src/poetry/utils/env/system_env.py index e088e684480..8ddef7b5608 100644 --- a/src/poetry/utils/env/system_env.py +++ b/src/poetry/utils/env/system_env.py @@ -13,7 +13,6 @@ from packaging.tags import interpreter_name from packaging.tags import interpreter_version from packaging.tags import sys_tags -from poetry.core.constraints.version import Version from poetry.utils.env.base_env import Env @@ -81,11 +80,6 @@ def get_marker_env(self) -> dict[str, Any]: "interpreter_version": interpreter_version(), } - def get_pip_version(self) -> Version: - from pip import __version__ - - return Version.parse(__version__) - def is_venv(self) -> bool: return self._path != self._base diff --git a/src/poetry/utils/env/virtual_env.py b/src/poetry/utils/env/virtual_env.py index 8a573426fec..d91330c2354 100644 --- a/src/poetry/utils/env/virtual_env.py +++ b/src/poetry/utils/env/virtual_env.py @@ -13,7 +13,6 @@ from typing import Any from packaging.tags import Tag -from poetry.core.constraints.version import Version from poetry.utils.env.base_env import Env from poetry.utils.env.script_strings import GET_BASE_PREFIX @@ -72,16 +71,6 @@ def get_marker_env(self) -> dict[str, Any]: env: dict[str, Any] = json.loads(output) return env - def get_pip_version(self) -> Version: - output = self.run_pip("--version") - output = output.strip() - - m = re.match("pip (.+?)(?: from .+)?$", output) - if not m: - return Version.parse("0.0") - - return Version.parse(m.group(1)) - def get_paths(self) -> dict[str, str]: output = self.run_python_script(GET_PATHS) paths: dict[str, str] = json.loads(output) diff --git a/tests/utils/env/test_env.py b/tests/utils/env/test_env.py index da481455b55..535a979e1bf 100644 --- a/tests/utils/env/test_env.py +++ b/tests/utils/env/test_env.py @@ -2,6 +2,7 @@ import contextlib import os +import re import site import subprocess import sys @@ -82,9 +83,8 @@ def test_env_commands_with_spaces_in_their_arg_work_as_expected( venv_path = tmp_path / "Virtual Env" manager.build_venv(venv_path) venv = VirtualEnv(venv_path) - assert venv.run("python", str(venv.pip), "--version").startswith( - f"pip {venv.pip_version} from " - ) + output = venv.run("python", str(venv.pip), "--version") + assert re.match(r"pip \S+ from", output) def test_env_get_supported_tags_matches_inside_virtualenv(