Skip to content

Commit 2cffb7e

Browse files
mstrathmanclaude
andcommitted
fix(wheels): produce a platform wheel (py3-none-<plat>), not pure-Python
cibuildwheel rejected the build because setup.py's build_py bundles a prebuilt loadable but didn't mark the distribution impure, so setuptools tagged the wheel py3-none-any. Override bdist_wheel to set root_is_pure=False and tag it py3-none-<platform> (the loadable is not a CPython extension, so it is ABI-agnostic but platform-specific). Limit cibuildwheel to one CPython build per platform, since every version now yields the same py3-none wheel. Verified locally: the wheel builds as py3-none-macosx_14_0_arm64. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 100c8a6 commit 2cffb7e

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎.github/workflows/wheels.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ jobs:
3232
with:
3333
package-dir: bindings/python
3434
env:
35-
# skip pypy and musl for the first cut; CPython manylinux + macOS cover
36-
# the target audience
37-
CIBW_SKIP: "pp* *-musllinux*"
35+
# the loadable is ABI-agnostic, so one CPython build per platform gives
36+
# one py3-none-<platform> wheel usable by any Python there. Skip musl.
37+
CIBW_BUILD: "cp312-*"
38+
CIBW_SKIP: "*-musllinux*"
3839
CIBW_BUILD_VERBOSITY: "1"
3940
- uses: actions/upload-artifact@v4
4041
with:

‎bindings/python/setup.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from setuptools import setup
99
from setuptools.command.build_py import build_py
1010

11+
try: # setuptools >= 70.1 vendors bdist_wheel; older builds use the wheel package
12+
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
13+
except ImportError:
14+
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
15+
1116
HERE = os.path.dirname(os.path.abspath(__file__))
1217
EXT = {"darwin": "dylib", "win32": "dll"}.get(sys.platform, "so")
1318

@@ -28,4 +33,19 @@ def run(self):
2833
super().run()
2934

3035

31-
setup(cmdclass={"build_py": Build})
36+
class BDistWheel(_bdist_wheel):
37+
"""The wheel ships a prebuilt loadable, so it is platform-specific but not
38+
tied to the CPython ABI. Tag it py3-none-<platform> rather than the default
39+
py3-none-any (which would claim the wheel is pure Python and makes
40+
cibuildwheel reject it)."""
41+
42+
def finalize_options(self):
43+
super().finalize_options()
44+
self.root_is_pure = False
45+
46+
def get_tag(self):
47+
_python, _abi, plat = super().get_tag()
48+
return "py3", "none", plat
49+
50+
51+
setup(cmdclass={"build_py": Build, "bdist_wheel": BDistWheel})

0 commit comments

Comments
 (0)