11# This file is used to rename the wheel generated via py_wheel with values
22# determined at runtime
33import sys , os , re , platform
4- from packaging import tags
4+ from packaging import tags , version
5+ from platform import python_version
6+ from enum import Enum
7+
8+
9+ class ABIVersion (Enum ):
10+ MANY_LINUX_X_Y = "manylinux_" + str (platform .libc_ver ()[1 ].replace ("." , "_" ))
11+ MANY_LINUX_2014 = "manylinux2014"
12+ MANY_LINUX_2010 = "manylinux2010"
13+
14+
15+ # We rely on the bundled pip versions installed with python to determine the
16+ # naming variant: https://github.com/pypa/manylinux
17+ #
18+ # NOTE: Order matters
19+ python_versions = {
20+ version .parse ("3.10.0" ): ABIVersion .MANY_LINUX_X_Y ,
21+ version .parse ("3.9.5" ): ABIVersion .MANY_LINUX_X_Y ,
22+ version .parse ("3.9.0" ): ABIVersion .MANY_LINUX_2014 ,
23+ version .parse ("3.8.10" ): ABIVersion .MANY_LINUX_X_Y ,
24+ version .parse ("3.8.4" ): ABIVersion .MANY_LINUX_2014 ,
25+ version .parse ("3.8.0" ): ABIVersion .MANY_LINUX_2010 , # Fails for aarch64
26+ }
527
628
729def main ():
@@ -17,17 +39,22 @@ def main():
1739 interpreter_version = tags .interpreter_version ()
1840 abi_tag = interpreter_name + interpreter_version
1941
20- # openmined.psi-1.0.0-INTERPRETER-ABI-PLATFORM.whl
42+ # openmined.psi-1.0.0-INTERPRETER-ABI-PLATFORM-ARCH .whl
2143 # INTERPRETER and ABI should be the same value
2244 outfile = re .sub (r"INTERPRETER" , abi_tag , inputfile )
2345 outfile = re .sub (r"ABI" , abi_tag , outfile )
2446 system = platform .system ()
2547
26- # Rename the wheel depending on the version of glibc
48+ # We rename the wheel depending on the version of python and glibc
2749 if system .lower () == "linux" :
28- version = platform .libc_ver ()[1 ]
29- glibc_version = version .replace ("." , "_" )
30- outfile = re .sub (r"GLIBC" , glibc_version , outfile )
50+ current_version = version .parse (python_version ())
51+ manylinux = ABIVersion .MANY_LINUX_X_Y .value
52+ for (ver , ml ) in python_versions .items ():
53+ if current_version >= ver :
54+ manylinux = ml .value
55+ break
56+
57+ outfile = re .sub (r"LINUX" , manylinux , outfile )
3158
3259 print ("renaming " , inputfile , outfile )
3360 os .rename (inputfile , outfile )
0 commit comments