Skip to content

Conversation

@lexdene
Copy link
Contributor

@lexdene lexdene commented Dec 9, 2025

Step 1: Standard bdist wheel command

Running the standard bdist_wheel command:

python setup.py bdist_wheel

produces a platform-specific wheel with a filename like:

greenify-0.5.0-cp39-cp39-linux_x86_64.whl

Attempting to install this wheel on a different Python minor version, such as Python 3.10, results in a platform compatibility error:

ERROR: greenify-0.5.0-cp39-cp39-linux_x86_64.whl is not a supported wheel on this platform.

Step 2: Adding limited api Flag

Adding the --py-limited-api parameter to the bdist_wheel command:

python setup.py bdist_wheel --py-limited-api=cp39

produces an ABI3 wheel package with a more compatible filename:

greenify-0.5.0-cp39-abi3-linux_x86_64.whl

However, the name of the compiled shared object (.so) file inside the wheel package is still incorrect:

greenify.cpython-39-x86_64-linux-gnu.so

While the wheel installs successfully on Python 3.10,
running tests raises an ImportError because the module cannot be found under the expected ABI-stable name:

ModuleNotFoundError: No module named 'greenify'

Step 3: Configuring Limited API in setup.py

The correct solution is to explicitly define the Limited API settings within the Extension configuration in setup.py:

setup(
    ext_modules=[
        Extension(
            define_macros=[
                ("Py_LIMITED_API", make_limited_api_macro("3.9")),
            ],
            py_limited_api=True, 
        )
    ]
)

This configuration ensures that both the wheel package name and the internal shared object file name are correct for ABI3 compatibility:

Correct Wheel Name:

greenify-0.5.0-cp39-abi3-linux_x86_64.whl

Correct .so File Name:

greenify.abi3.so

This wheel can now be installed and tested successfully across the specified range of target Python versions, from Python 3.9 to Python 3.14.

@lexdene lexdene merged commit 698a516 into douban:master Dec 9, 2025
14 checks passed
@lexdene lexdene deleted the chore_limited_api branch December 9, 2025 08:35
@lexdene
Copy link
Contributor Author

lexdene commented Jan 8, 2026

fix #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant