From 5b646cdd2dce68aaed2778c248f11b2ae4dd1d9d Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 17:38:51 -0700 Subject: [PATCH 1/7] CMakeLists.txt: Specify nanobind STABLE_ABI flag --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 335c309..0ac0d9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ add_executable(sleigh install(TARGETS sleigh DESTINATION bin) nanobind_add_module(pypcode_native + STABLE_ABI pypcode/pypcode_native.cpp ${SLEIGH_COMMON} ${ZLIB} From 39d72441956bb08cb22a626879655dcf26bf7cf1 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 17:53:47 -0700 Subject: [PATCH 2/7] pyproject.toml: Add wheel dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2895b73..97db858 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ docs = [ ] [build-system] -requires = [ "setuptools", "nanobind", "cmake" ] +requires = [ "setuptools", "nanobind", "cmake", "wheel" ] build-backend = "setuptools.build_meta" [tool.setuptools] From a3ad1e239dd9ea65974e2de4a97950d62ec28f12 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 18:00:14 -0700 Subject: [PATCH 3/7] ci: Install wheel manually, for lint step --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d46df5..3ddfb6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: with: python-version: '3.10' - run: | - python -m pip install pylint + python -m pip install pylint wheel python -m pip install -e . - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 with: From e87649d2d732cb9541ffd15bd6bc1c43baf4f599 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 18:01:58 -0700 Subject: [PATCH 4/7] pyproject.toml: Migrate pylint dependencies in --- .github/workflows/build.yml | 3 +-- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ddfb6d..4e88cef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,8 +15,7 @@ jobs: with: python-version: '3.10' - run: | - python -m pip install pylint wheel - python -m pip install -e . + python -m pip install -e .[pylint] - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 with: extra_args: pylint --all-files diff --git a/pyproject.toml b/pyproject.toml index 97db858..98bd03c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ docs = [ "sphinx", "sphinx-autodoc-typehints", ] +pylint = [ "pylint", "wheel" ] [build-system] requires = [ "setuptools", "nanobind", "cmake", "wheel" ] From 7e7540a8cc25f0027869fd1710402a1112afed35 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 17:47:21 -0700 Subject: [PATCH 5/7] setup.py: Specify abi3 compat platform tag when built with cp312+ --- setup.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9348861..c0f127e 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,22 @@ import sys from setuptools import setup from setuptools.command.build_ext import build_ext +from wheel.bdist_wheel import bdist_wheel + + +class bdist_wheel_abi3(bdist_wheel): + """ + Overrides bdist_wheel to provide stable ABI platform tag. + """ + + def get_tag(self): + python, abi, plat = super().get_tag() + + if python.startswith("cp") and sys.version_info >= (3, 12): + # on CPython, our wheels are abi3 and compatible back to 3.12 + return "cp312", "abi3", plat + + return python, abi, plat class BuildExtension(build_ext): @@ -99,5 +115,5 @@ def add_pkg_data_dirs(pkg, dirs): package_data={ "pypcode": add_pkg_data_dirs("pypcode", ["bin", "docs", "processors"]) + ["py.typed", "pypcode_native.pyi"] }, - cmdclass={"build_ext": BuildExtension}, + cmdclass={"build_ext": BuildExtension, "bdist_wheel": bdist_wheel_abi3}, ) From 2f906b2423394ece558d2513c97017d90bb6166b Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 17:39:21 -0700 Subject: [PATCH 6/7] ci: With stable ABI enabled for 3.12+, drop cp313 builds --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e88cef..9b683ec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,7 @@ jobs: runs-on: ${{ matrix.platform.os }} strategy: matrix: - py: [cp310, cp311, cp312, cp313] + py: [cp310, cp311, cp312] platform: - { arch: x86_64, os: windows-latest, wheel_tag: win_amd64 } - { arch: x86_64, os: macos-13, wheel_tag: macosx_x86_64 } From e413564a1a226719120c14b30a00dd1798f99094 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 19 Sep 2025 18:21:54 -0700 Subject: [PATCH 7/7] ci: Test ABI3 wheels on other Python versions --- .github/workflows/build.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b683ec..692d12c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,35 @@ jobs: name: ${{ matrix.py }}-${{ matrix.platform.wheel_tag }} path: ./wheelhouse/*.whl + test_abi3_wheels: + needs: build_wheels + name: Test with Python ${{ matrix.py }} on ${{ matrix.platform.os }} + runs-on: ${{ matrix.platform.os }} + strategy: + matrix: + py: [ "3.13" ] + platform: + - { arch: x86_64, os: windows-latest, wheel_tag: win_amd64 } + - { arch: x86_64, os: macos-13, wheel_tag: macosx_x86_64 } + - { arch: arm64, os: macos-latest, wheel_tag: macosx_arm64 } + - { arch: x86_64, os: ubuntu-latest, wheel_tag: manylinux_x86_64 } + - { arch: aarch64, os: ubuntu-24.04-arm, wheel_tag: manylinux_aarch64 } + steps: + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + path: artifacts + merge-multiple: true + - name: Unpack source distribution + shell: bash + run: tar --strip-components 1 -xvf artifacts/*.tar.gz + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: ${{ matrix.py }} + - name: Install wheel and run tests + run: | + python -m pip install --no-index --find-links=artifacts pypcode + cd tests; python -m unittest discover -v . + build_docs: name: Build docs runs-on: ubuntu-latest @@ -87,7 +116,7 @@ jobs: upload_pypi: name: Upload wheels to PyPI - needs: [lint, build_docs, build_sdist, build_wheels] + needs: [lint, build_docs, build_sdist, build_wheels, test_abi3_wheels] environment: name: pypi url: https://pypi.org/p/pypcode