helpers.py (poetry-1.1.15) | : | helpers.py (poetry-1.2.0) | ||
---|---|---|---|---|
from typing import Optional | from __future__ import annotations | |||
from typing import Union | ||||
from poetry.core.semver import Version | from pathlib import Path | |||
from poetry.utils._compat import Path | from typing import TYPE_CHECKING | |||
from typing import Any | ||||
def build_venv(path, executable=None): # type: (Union[Path,str], Optional[str]) | from poetry.core.semver.version import Version | |||
-> () | ||||
if TYPE_CHECKING: | ||||
from collections.abc import Callable | ||||
from poetry.core.version.pep440.version import PEP440Version | ||||
VERSION_3_7_1 = Version.parse("3.7.1") | ||||
def build_venv(path: Path | str, **_: Any) -> None: | ||||
Path(path).mkdir(parents=True, exist_ok=True) | Path(path).mkdir(parents=True, exist_ok=True) | |||
def check_output_wrapper(version=Version.parse("3.7.1")): | def check_output_wrapper( | |||
def check_output(cmd, *args, **kwargs): | version: PEP440Version = VERSION_3_7_1, | |||
) -> Callable[[str, Any, Any], str]: | ||||
def check_output(cmd: str, *_: Any, **__: Any) -> str: | ||||
if "sys.version_info[:3]" in cmd: | if "sys.version_info[:3]" in cmd: | |||
return version.text | return version.text | |||
elif "sys.version_info[:2]" in cmd: | elif "sys.version_info[:2]" in cmd: | |||
return "{}.{}".format(version.major, version.minor) | return f"{version.major}.{version.minor}" | |||
elif '-c "import sys; print(sys.executable)"' in cmd: | ||||
return f"/usr/bin/{cmd.split()[0]}" | ||||
else: | else: | |||
return str(Path("/prefix")) | return str(Path("/prefix")) | |||
return check_output | return check_output | |||
End of changes. 5 change blocks. | ||||
9 lines changed or deleted | 21 lines changed or added |