diff --git a/src/poetry/utils/env.py b/src/poetry/utils/env.py index 79a78df9797..ab645bd7c08 100644 --- a/src/poetry/utils/env.py +++ b/src/poetry/utils/env.py @@ -5,7 +5,6 @@ import hashlib import itertools import json -import logging import os import platform import plistlib @@ -37,7 +36,6 @@ from poetry.core.utils.helpers import temporary_directory from virtualenv.seed.wheels.embed import get_embed_wheel -from poetry.exceptions import PoetryException from poetry.utils._compat import WINDOWS from poetry.utils._compat import decode from poetry.utils._compat import encode @@ -61,9 +59,6 @@ from poetry.poetry import Poetry -logger = logging.getLogger(__name__) - - GET_SYS_TAGS = f""" import importlib.util import json @@ -228,11 +223,6 @@ def _version_nodot(version): """ -# This should be dropped when Poetry removes python2 support completely -def _is_python2_exec(executable: str) -> bool: - return re.match(r".*2.|.2\..", executable) is not None - - class SitePackages: def __init__( self, @@ -578,9 +568,6 @@ def activate(self, python: str, io: IO) -> Env: python = self._full_python_path(python) - if _is_python2_exec(python): - io.write_error_line("Poetry no longer supports Python 2.7 environments") - try: python_version_string = decode( subprocess.check_output( @@ -923,10 +910,6 @@ def create_venv( python = "python" + python_to_try - if _is_python2_exec(python): - error_message = "Poetry no longer supports Python 2.7 environments." - raise PoetryException(error_message) - if io.is_debug(): io.write_line(f"Trying {python}") @@ -985,7 +968,6 @@ def create_venv( f"Creating virtualenv {name} in" f" {venv_path if not WINDOWS else get_real_windows_path(venv_path)!s}" ) - else: create_venv = False if force: @@ -1064,10 +1046,6 @@ def build_venv( if isinstance(executable, Path): executable = executable.resolve().as_posix() - if _is_python2_exec(executable): - error_message = "Poetry no longer supports Python 2.7 environments." - raise PoetryException(error_message) - args = [ "--no-download", "--no-periodic-update", @@ -1703,13 +1681,9 @@ def get_pip_command(self, embedded: bool = False) -> list[str]: ] def get_supported_tags(self) -> list[Tag]: - if self.get_version_info() < (3, 0, 0): - error_message = """ - Poetry no longer supports Python 2.7 environments. - """ - raise PoetryException(error_message) output = self.run_python_script(GET_SYS_TAGS) assert isinstance(output, str) + return [Tag(*t) for t in json.loads(output)] def get_marker_env(self) -> dict[str, Any]: