Skip to content

Commit

Permalink
feat: Include abiflags in version dectection (enabling 3.13t)
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Dec 8, 2024
1 parent d835370 commit 4daf43a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/tox_gh_actions/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,27 @@ def get_python_version_keys() -> List[str]:
Examples:
- CPython 3.8.z => [3.8, 3]
- PyPy 3.6 (v7.3.z) => [pypy-3.6, pypy-3, pypy3]
- PyPy 3.6 (v7.3.z) => [pypy-3.6, pypy-3]
- Pyston based on Python CPython 3.8.8 (v2.2) => [pyston-3.8, pyston-3]
- CPython 3.13.z (free-threading build) => [3.13t, 3.13, 3]
"""
major_version = str(sys.version_info[0])
major_minor_version = ".".join([str(i) for i in sys.version_info[:2]])
major, minor = sys.version_info[:2]
if "PyPy" in sys.version:
return [
"pypy-" + major_minor_version,
"pypy-" + major_version,
f"pypy-{major}.{minor}",
f"pypy-{major}",
]
elif hasattr(sys, "pyston_version_info"): # Pyston
return [
"pyston-" + major_minor_version,
"pyston-" + major_version,
f"pyston-{major}.{minor}",
f"pyston-{major}",
]
else:
# Assume this is running on CPython
return [major_minor_version, major_version]
ret = [f"{major}.{minor}", f"{major}"]
if sys.abiflags:
ret.insert(0, f"{major}.{minor}{sys.abiflags}")
return ret


def is_running_on_actions() -> bool:
Expand Down
13 changes: 12 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,29 +247,40 @@ def test_get_envlist_from_factors(


@pytest.mark.parametrize(
"version,info,expected",
"version,info,abiflags,expected",
[
(
"3.8.1 (default, Jan 22 2020, 06:38:00) \n[GCC 9.2.0]",
(3, 8, 1, "final", 0),
"",
["3.8", "3"],
),
(
"3.6.9 (1608da62bfc7, Dec 23 2019, 10:50:04)\n"
"[PyPy 7.3.0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]",
(3, 6, 9, "final", 0),
"",
["pypy-3.6", "pypy-3"],
),
(
"3.13.0 experimental free-threading build (main, Oct 16 2024, 03:26:14) "
"[Clang 18.1.8 ]\n",
(3, 13, 0, "final", 0),
"t",
["3.13t", "3.13", "3"],
),
],
)
def test_get_version_keys(
mocker: MockerFixture,
version: str,
info: Tuple[int, int, int, str, int],
abiflags: str,
expected: List[str],
) -> None:
mocker.patch("tox_gh_actions.plugin.sys.version", version)
mocker.patch("tox_gh_actions.plugin.sys.version_info", info)
mocker.patch("tox_gh_actions.plugin.sys.abiflags", abiflags)
assert plugin.get_python_version_keys() == expected


Expand Down

0 comments on commit 4daf43a

Please sign in to comment.