Skip to content

Commit

Permalink
env: add support for untagged CPython builds where platform.python_ve…
Browse files Browse the repository at this point in the history
…rsion() ends with a "+"

works around python/cpython#99968
  • Loading branch information
radoering authored and neersighted committed Mar 23, 2024
1 parent 2a2abce commit 8e1e87c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/poetry/utils/env/script_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _version_nodot(version):
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"python_full_version": platform.python_version().rstrip("+"),
"platform_python_implementation": platform.python_implementation(),
"python_version": ".".join(platform.python_version_tuple()[:2]),
"sys_platform": sys.platform,
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/utils/env/system_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def get_marker_env(self) -> dict[str, Any]:
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
# Workaround for https://github.com/python/cpython/issues/99968
"python_full_version": platform.python_version().rstrip("+"),
"platform_python_implementation": platform.python_implementation(),
"python_version": ".".join(platform.python_version().split(".")[:2]),
"sys_platform": sys.platform,
Expand Down
19 changes: 19 additions & 0 deletions tests/utils/env/test_system_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations

import sys

from pathlib import Path
from typing import TYPE_CHECKING

from poetry.utils.env import SystemEnv


if TYPE_CHECKING:
from pytest_mock import MockerFixture


def test_get_marker_env_untagged_cpython(mocker: MockerFixture) -> None:
mocker.patch("platform.python_version", return_value="3.11.9+")
env = SystemEnv(Path(sys.prefix))
marker_env = env.get_marker_env()
assert marker_env["python_full_version"] == "3.11.9"

0 comments on commit 8e1e87c

Please sign in to comment.