Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: enable ABI3 forward-compatible wheels for CPython #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.11.2

- name: Build wheels
run: python -m cibuildwheel --output-dir dist
uses: pypa/[email protected]
with:
output-dir: dist

- uses: actions/upload-artifact@v3
with:
Expand All @@ -39,19 +36,34 @@ jobs:
- uses: actions/setup-python@v3

- name: Create source distribution
run: python ./setup.py sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: ./dist/*.tar.gz

audit_abi3_wheels:
name: Audit ABI3 wheels
runs-on: ubuntu-latest
needs:
- build_wheels

steps:
- uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: ./dist/
- uses: actions/setup-python@v3
- run: pipx run abi3audit dist/*abi3*.whl

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs:
- build_wheels
- build_sdist
- audit_abi3_wheels

steps:
- uses: actions/download-artifact@v3
Expand Down
35 changes: 35 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
__author__ = "Konstantin Weddige"
import sysconfig
from setuptools import setup, Extension
from wheel.bdist_wheel import bdist_wheel


MINIMAL_PYTHON_VERSION = (3, 6)

# build with Py_LIMITED_API unless in freethreading build (which does not currently
# support the limited API in py313t)
USE_PY_LIMITED_API = not sysconfig.get_config_var("Py_GIL_DISABLED")
define_macros = []
if USE_PY_LIMITED_API:
define_macros.append(("Py_LIMITED_API", "0x030600f0"))

def _get_python_requires():
return f">={'.'.join(str(_) for _ in MINIMAL_PYTHON_VERSION)}"

def _get_cpython_tag():
return f"cp{''.join(str(_) for _ in MINIMAL_PYTHON_VERSION[:2])}"

with open("README.rst", "r", encoding="utf-8") as fh:
long_description = fh.read()

class bdist_wheel_abi3(bdist_wheel):
def get_tag(self):
python, abi, plat = super().get_tag()

if python.startswith("cp") and USE_PY_LIMITED_API:
# on CPython, our wheels are abi3
# and compatible down to MINIMAL_PYTHON_VERSION
return _get_cpython_tag(), "abi3", plat

return python, abi, plat



setup(
name="MiniballCpp",
version="0.2.3",
Expand All @@ -21,8 +52,11 @@
["src/miniballmodule.cpp"],
include_dirs=["src"],
language="c++",
define_macros=define_macros,
py_limited_api=USE_PY_LIMITED_API,
),
],
python_requires=_get_python_requires(),
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
Expand All @@ -31,4 +65,5 @@
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
],
cmdclass={"bdist_wheel": bdist_wheel_abi3},
)