33from typing import Tuple
44
55from setuptools import setup
6-
7- try :
8- from setuptools .command .bdist_wheel import bdist_wheel
9- except ImportError :
10- from wheel .bdist_wheel import bdist_wheel # type: ignore
6+ from setuptools .command .bdist_wheel import bdist_wheel
7+ from setuptools .command .build_ext import build_ext
8+ from setuptools .dist import Distribution
119
1210
1311def copy_binary_files (net_rid : str ):
@@ -48,12 +46,19 @@ def copy_binary_files(net_rid: str):
4846
4947
5048class bdist_wheel_abi3 (bdist_wheel ):
51- def finalize_options (self ):
52- super ().finalize_options ()
49+ def get_tag (self ) -> Tuple [str , str , str ]:
5350 self .root_is_pure = False
51+ python , abi , plat = super ().get_tag ()
52+ self .root_is_pure = True
53+ if python .startswith ("cp" ):
54+ # on CPython, our wheels are abi3 and compatible back to 3.7
55+ return "cp36" , "abi3" , plat
56+ return python , abi , plat
57+
5458
59+ class build_ext_c (build_ext ):
5560 def run (self ):
56- platform_tag = self .get_tag ()[ 2 ]
61+ platform_tag = self .plat_name . replace ( "-" , "_" )
5762 if platform_tag .startswith ("win" ):
5863 net_rid = BDIST_TAG_MAP_WIN [platform_tag ]
5964 elif platform_tag .startswith ("macosx" ):
@@ -65,14 +70,16 @@ def run(self):
6570 copy_binary_files (net_rid )
6671 super ().run ()
6772
68- def get_tag ( self ) -> Tuple [ str , str , str ]:
69- python , abi , plat = super (). get_tag ()
70- if python . startswith ( "cp" ):
71- # on CPython, our wheels are abi3 and compatible back to 3.7
72- return "cp36" , "abi3" , plat
73- return python , abi , plat
73+
74+ class UnpureDistribution ( Distribution ):
75+ """Distribution which is not marked as pure, so that wheels are built as platform-specific"""
76+
77+ def is_pure ( self ) -> bool :
78+ return False
7479
7580
7681setup (
77- cmdclass = {"bdist_wheel" : bdist_wheel_abi3 },
82+ cmdclass = {"bdist_wheel" : bdist_wheel_abi3 , "build_ext" : build_ext_c },
83+ distclass = UnpureDistribution ,
84+ zip_safe = False ,
7885)
0 commit comments