diff --git a/newsfragments/4674.bugfix.rst b/newsfragments/4674.bugfix.rst new file mode 100644 index 0000000000..9a6d2454ab --- /dev/null +++ b/newsfragments/4674.bugfix.rst @@ -0,0 +1 @@ +Fix the ABI tag when building a wheel using the debug build of Python 3.13 on Windows. Previously, the ABI tag was missing the ``"d"`` flag. diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index f377cd5ee6..3b64d6270e 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -129,6 +129,9 @@ def get_abi_tag() -> str | None: elif soabi and impl == "cp" and soabi.startswith("cp"): # Windows abi = soabi.split("-")[0] + if hasattr(sys, "gettotalrefcount"): + # using debug build; append "d" flag + abi += "d" elif soabi and impl == "pp": # we want something like pypy36-pp73 abi = "-".join(soabi.split("-")[:2]) diff --git a/setuptools/tests/test_bdist_wheel.py b/setuptools/tests/test_bdist_wheel.py index 47200d0a26..141ef716ab 100644 --- a/setuptools/tests/test_bdist_wheel.py +++ b/setuptools/tests/test_bdist_wheel.py @@ -470,6 +470,12 @@ def test_get_abi_tag_windows(monkeypatch): monkeypatch.setattr(tags, "interpreter_name", lambda: "cp") monkeypatch.setattr(sysconfig, "get_config_var", lambda x: "cp313-win_amd64") assert get_abi_tag() == "cp313" + monkeypatch.setattr(sys, "gettotalrefcount", lambda: 1, False) + assert get_abi_tag() == "cp313d" + monkeypatch.setattr(sysconfig, "get_config_var", lambda x: "cp313t-win_amd64") + assert get_abi_tag() == "cp313td" + monkeypatch.delattr(sys, "gettotalrefcount") + assert get_abi_tag() == "cp313t" def test_get_abi_tag_pypy_old(monkeypatch):