Skip to content

Commit

Permalink
Revert changes to env logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus committed Aug 25, 2022
1 parent ea87a99 commit 589a5e5
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import hashlib
import itertools
import json
import logging
import os
import platform
import plistlib
Expand Down Expand Up @@ -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
Expand All @@ -61,9 +59,6 @@
from poetry.poetry import Poetry


logger = logging.getLogger(__name__)


GET_SYS_TAGS = f"""
import importlib.util
import json
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"<debug>Trying {python}</debug>")

Expand Down Expand Up @@ -985,7 +968,6 @@ def create_venv(
f"Creating virtualenv <c1>{name}</> in"
f" {venv_path if not WINDOWS else get_real_windows_path(venv_path)!s}"
)

else:
create_venv = False
if force:
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 589a5e5

Please sign in to comment.