Skip to content

Commit

Permalink
BLD: enable ABI3 forward-compatible wheels for CPython
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Jul 30, 2023
1 parent 857b73e commit cac1b4c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ 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:
name: python-package-distributions
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
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
__author__ = "Konstantin Weddige"
from setuptools import setup, Extension
from wheel.bdist_wheel import bdist_wheel


# keep in sync with Py_LIMITED_API
MINIMAL_PYTHON_VERSION = (3, 6)

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"):
# 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 +43,10 @@
["src/miniballmodule.cpp"],
include_dirs=["src"],
language="c++",
py_limited_api=True,
),
],
python_requires=_get_python_requires(),
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
Expand All @@ -31,4 +55,5 @@
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
],
cmdclass={"bdist_wheel": bdist_wheel_abi3},
)
3 changes: 3 additions & 0 deletions src/Miniball.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include <ctime>
#include <limits>

// keep in sync with python_requires
#define Py_LIMITED_API 0x030600f0

namespace Miniball {

// Global Functions
Expand Down

0 comments on commit cac1b4c

Please sign in to comment.