diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index abe182c..3964dc9 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -89,6 +89,7 @@ jobs: path: dist merge-multiple: true - run: uvx twine check dist/*.whl + - run: uvx abi3audit dist/*abi3*.whl publish: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') diff --git a/setup.py b/setup.py index f5557cc..aff0187 100755 --- a/setup.py +++ b/setup.py @@ -1,14 +1,28 @@ #!/usr/bin/env python """Setup for the siphashc module.""" +import sysconfig + from setuptools import Extension, setup +define_macros = [("Py_LIMITED_API", "0x030A0000")] +bdist_options = {"py_limited_api": "cp310"} + +# Free-threaded Python is not compatible with ABI3, see +# https://github.com/python/cpython/issues/111506 +if sysconfig.get_config_var("Py_GIL_DISABLED"): + define_macros = [] + bdist_options = {} + setup( ext_modules=[ Extension( name="siphashc", sources=["siphashc.c", "siphash/siphash.c"], language="c", + define_macros=define_macros, + py_limited_api=True, ), ], + options={"bdist_wheel": bdist_options}, )