diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8576283..b27a7a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,9 @@ jobs: with: package-dir: ./PythonAPI + - name: Run abi3audit + run: uvx abi3audit --report ./wheelhouse/*-abi3-*.whl + - uses: actions/upload-artifact@v4 with: name: pycocotools-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ strategy.job-index }} diff --git a/PythonAPI/setup.py b/PythonAPI/setup.py index 2b9a34e..04f9a12 100644 --- a/PythonAPI/setup.py +++ b/PythonAPI/setup.py @@ -1,17 +1,33 @@ """To compile and install locally run "python setup.py build_ext --inplace". To install library to Python site-packages run "python -m pip install --use-feature=in-tree-build ." """ +import platform +import sys +import sysconfig from pathlib import Path from setuptools import setup, Extension import numpy as np from Cython.Build import cythonize +py_gil_disabled = sysconfig.get_config_var('Py_GIL_DISABLED') +use_limited_api = not py_gil_disabled and platform.python_implementation() == 'CPython' and sys.version_info >= (3, 12) +if use_limited_api: + limited_api_args = { + "py_limited_api": True, + "define_macros": [("Py_LIMITED_API", "0x030C0000")], + } + options = {"bdist_wheel": {"py_limited_api": "cp312"}} +else: + limited_api_args = {} + options = {} + ext_modules = [ Extension( 'pycocotools._mask', sources=['./common/maskApi.c', 'pycocotools/_mask.pyx'], include_dirs=[np.get_include(), './common'], + **limited_api_args ) ] @@ -36,6 +52,7 @@ extras_require={ 'all': ['matplotlib>=2.1.0'], }, - version='2.0.9', + version='2.0.10', ext_modules=cythonize(ext_modules), + options=options, )