|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import sys |
| 16 | + |
15 | 17 | from hatchling.builders.hooks.plugin.interface import BuildHookInterface |
16 | 18 |
|
17 | 19 |
|
18 | 20 | class CustomBuildHook(BuildHookInterface): |
19 | 21 | def initialize(self, version, build_data): |
20 | | - """Force platform-specific wheel due to native libraries""" |
| 22 | + """Force platform-specific wheel with py3-none tag. |
| 23 | +
|
| 24 | + The native libraries (.so, .dylib, .dll) are not Python C extensions - |
| 25 | + they're standalone FFI libraries loaded at runtime. This means they |
| 26 | + don't depend on a specific CPython ABI, so we use py3-none to indicate |
| 27 | + compatibility with any Python 3.x version while keeping the platform tag. |
| 28 | + """ |
21 | 29 | build_data["pure_python"] = False |
22 | | - build_data["infer_tag"] = True |
| 30 | + build_data["infer_tag"] = False |
| 31 | + |
| 32 | + # Get the platform tag using hatchling's logic (handles MACOSX_DEPLOYMENT_TARGET, etc.) |
| 33 | + from packaging.tags import sys_tags |
| 34 | + |
| 35 | + tag = next( |
| 36 | + t for t in sys_tags() if "manylinux" not in t.platform and "musllinux" not in t.platform |
| 37 | + ) |
| 38 | + platform = tag.platform |
| 39 | + |
| 40 | + if sys.platform == "darwin": |
| 41 | + from hatchling.builders.macos import process_macos_plat_tag |
| 42 | + |
| 43 | + platform = process_macos_plat_tag(platform, compat=True) |
| 44 | + |
| 45 | + build_data["tag"] = f"py3-none-{platform}" |
0 commit comments