msys2-contrib / cpython-mingw

A friendly fork of CPython which adds support for Mingw-w64 + clang/gcc. See https://github.com/msys2-contrib/cpython-mingw/wiki for details
https://github.com/msys2-contrib/cpython-mingw/wiki
Other
38 stars 11 forks source link

py_limited_api support in setuptools #149

Closed lazka closed 1 year ago

lazka commented 1 year ago

In theory you can build an abi3 extension via somthing like:

        Extension(
            "spam",
            sources=["spam.c"],
            define_macros=[("Py_LIMITED_API", "0x03060000")],
            py_limited_api=True,
        )

setuptools itself does not contain any logic to link this to a different library though, nor does distutils, this is handled via pragma in cpython core: https://github.com/python/cpython/blob/47022a079eb9d2a2af781abae3de4a71f80247c2/PC/pyconfig.h#L313 which doesn't work outside of MSVC.

Which means with mingw-w64 we need to patch setuptools to extend distutils in case py_limited_api is passed and override get_libraries() https://github.com/pypa/distutils/blob/5a8ca1b0f362968a29f2fb9c107cc0d4d79c3263/distutils/command/build_ext.py#L735

fun....

lazka commented 1 year ago

This is now patched in https://github.com/msys2/MINGW-packages/pull/18232, as we can't really help with this in cpython directly I'm closing this.