Skip to content

Commit 2b56523

Browse files
mstrathmanclaude
andcommitted
fix(wheels): install to platlib so auditwheel can repair the linux wheel
The prior fix tagged the wheel platform-specific but the .so still landed in purelib, so auditwheel rejected it ("shared library in purelib folder; must be platlib compliant"). Declare has_ext_modules via a BinaryDistribution so setuptools installs the loadable to platlib (Root-Is-Purelib: false); the bdist_wheel override keeps the ABI-agnostic py3-none-<platform> tag. Verified locally. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d93bbfb commit 2b56523

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

‎bindings/python/setup.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import subprocess
66
import sys
77

8-
from setuptools import setup
8+
from setuptools import Distribution, setup
99
from setuptools.command.build_py import build_py
1010

1111
try: # setuptools >= 70.1 vendors bdist_wheel; older builds use the wheel package
@@ -33,11 +33,20 @@ def run(self):
3333
super().run()
3434

3535

36+
class BinaryDistribution(Distribution):
37+
"""The package ships a prebuilt loadable. Declaring ext modules makes
38+
setuptools install it to platlib (not purelib, which auditwheel rejects)
39+
and marks the wheel platform-specific."""
40+
41+
def has_ext_modules(self):
42+
return True
43+
44+
3645
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)."""
46+
"""The loadable is not a CPython extension, so the wheel is platform-specific
47+
but ABI-agnostic. Tag it py3-none-<platform> rather than cp3x-cp3x-<platform>
48+
(any Python on that platform can load it), and not py3-none-any (which would
49+
claim it is pure Python and makes cibuildwheel reject it)."""
4150

4251
def finalize_options(self):
4352
super().finalize_options()
@@ -48,4 +57,5 @@ def get_tag(self):
4857
return "py3", "none", plat
4958

5059

51-
setup(cmdclass={"build_py": Build, "bdist_wheel": BDistWheel})
60+
setup(distclass=BinaryDistribution,
61+
cmdclass={"build_py": Build, "bdist_wheel": BDistWheel})

0 commit comments

Comments
 (0)