diff --git a/src/tox_gh_actions/plugin.py b/src/tox_gh_actions/plugin.py index 65693d8..1fcbc9a 100644 --- a/src/tox_gh_actions/plugin.py +++ b/src/tox_gh_actions/plugin.py @@ -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: diff --git a/tests/test_plugin.py b/tests/test_plugin.py index d841d6a..0c276fd 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -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