diff --git a/mypyc/options.py b/mypyc/options.py index a116c549cbf6..9b092859ffef 100644 --- a/mypyc/options.py +++ b/mypyc/options.py @@ -96,7 +96,7 @@ def __repr__(self) -> str: def replace_ext_suffix_version(suffix: str, version: tuple[int, int], free_threaded: bool) -> str: """Replace the Python version tag in an extension suffix such as ".cp313-win_amd64.pyd".""" tag = f"{version[0]}{version[1]}{'t' if free_threaded else ''}" - result, n = re.subn(r"(\.cpython-|\.cp)\d+t?(?=-)", rf"\g<1>{tag}", suffix, count=1) + result, n = re.subn(r"(\.cpython-|\.cp)\d+t?(?=d?-)", rf"\g<1>{tag}", suffix, count=1) if n == 0: raise ValueError( f'Can\'t target Python {version[0]}.{version[1]}{"t" if free_threaded else ""}: ' diff --git a/mypyc/test/test_target_python.py b/mypyc/test/test_target_python.py index 1ac87d0ef77c..77e7767a5e23 100644 --- a/mypyc/test/test_target_python.py +++ b/mypyc/test/test_target_python.py @@ -40,6 +40,8 @@ def test_ext_suffix(self) -> None: for host, target, expected in [ (".cpython-313-x86_64-linux-gnu.so", "3.14t", ".cpython-314t-x86_64-linux-gnu.so"), (".cpython-314t-darwin.so", "3.13", ".cpython-313-darwin.so"), + (".cpython-312d-x86_64-linux-gnu.so", "3.14t", ".cpython-314td-x86_64-linux-gnu.so"), + (".cpython-314td-darwin.so", "3.12", ".cpython-312d-darwin.so"), (".cp313-win_amd64.pyd", "3.14t", ".cp314t-win_amd64.pyd"), ("_d.cp313t-win_amd64.pyd", "3.12", "_d.cp312-win_amd64.pyd"), ]: