Skip to content

[Python] limited_api argument is not respected #15172

@moi15moi

Description

@moi15moi

Describe the bug
On Windows, the limited_api argument of Python3.extension_module is not respected.
On ubuntu or macos, I don't have this issue.

To Reproduce
I created a repo to show you a minimal example: https://github.com/moi15moi/mesontest

I build my python wheels in my CI by using meson-python (https://github.com/moi15moi/mesontest/actions/runs/18805902025).

If python is 3.12 or more, I use the limited api like this: https://github.com/moi15moi/mesontest/blob/de1668ff7a522e214d9282de8c2993affde8aea6/meson.build#L14-L28
I installed mesontest-0.2.1-cp312-abi3-win_amd64.whl (which is builded with the CI) in a python 3.13 environment.
If I try to import my project, I get this error:

ImportError while importing test module 'D:\a\mesontest\mesontest\tests\test_my_module.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\hostedtoolcache\windows\Python\3.13.9\x64\Lib\importlib\__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests\test_my_module.py:1: in <module>
    import my_module
E   ImportError: DLL load failed while importing my_module: The specified module could not be found.

Note that if I use objdump, I can see that it link to python312.dll instead of python3.dll, but I don't know why it happen.

Expected behavior
The wheel should be usable on Python 3.13 because I am using the limited abi.

system parameters
Type of build: Native build
OS: Windows
meson version: master
Ninja version: 1.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions