|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -from sysconfig import get_platform |
| 15 | +import sys |
16 | 16 |
|
17 | 17 | from hatchling.builders.hooks.plugin.interface import BuildHookInterface |
18 | 18 |
|
19 | 19 |
|
20 | 20 | class CustomBuildHook(BuildHookInterface): |
21 | 21 | def initialize(self, version, build_data): |
22 | | - """Force platform-specific wheel with py3-none tag.""" |
| 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 | + """ |
23 | 29 | build_data["pure_python"] = False |
24 | 30 | build_data["infer_tag"] = False |
25 | | - build_data["tag"] = f"py3-none-{get_platform().replace('-', '_').replace('.', '_')}" |
| 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