11import os
22import platform
33import shutil
4+ import struct
45import subprocess
56import sys
67
@@ -27,6 +28,24 @@ def build(package, configure_args=[]):
2728 os .chdir (build_dir )
2829
2930
31+ def get_platform ():
32+ system = platform .system ()
33+ if system == "Linux" :
34+ return "manylinux_%s" % platform .machine ()
35+ elif system == "Darwin" :
36+ # cibuildwheel sets ARCHFLAGS:
37+ # https://github.com/pypa/cibuildwheel/blob/5255155bc57eb6224354356df648dc42e31a0028/cibuildwheel/macos.py#L207-L220
38+ machine = os .environ ["ARCHFLAGS" ].split ()[1 ]
39+ return "macosx_%s" % machine
40+ elif system == "Windows" :
41+ if struct .calcsize ("P" ) * 8 == 64 :
42+ return "win_amd64"
43+ else :
44+ return "win32"
45+ else :
46+ raise Exception ("Unsupported platfom %s" % sys .platform )
47+
48+
3049def prepend_env (name , new , separator = " " ):
3150 old = os .environ .get (name )
3251 if old :
@@ -58,19 +77,10 @@ def run(cmd):
5877 subprocess .run (cmd , check = True , stderr = sys .stderr .buffer , stdout = sys .stdout .buffer )
5978
6079
61- system = platform .system ()
62- if system == "Linux" :
63- machine = platform .machine ()
80+ output_dir = os .path .abspath ("output" )
81+ if platform .system () == "Linux" :
6482 output_dir = "/output"
65- output_tarball = os .path .join (output_dir , f"codecs-manylinux_{ machine } .tar.gz" )
66- elif system == "Darwin" :
67- # cibuildwheel sets ARCHFLAGS:
68- # https://github.com/pypa/cibuildwheel/blob/5255155bc57eb6224354356df648dc42e31a0028/cibuildwheel/macos.py#L207-L220
69- machine = os .environ ["ARCHFLAGS" ].split ()[1 ]
70- output_dir = os .path .abspath ("output" )
71- output_tarball = os .path .join (output_dir , f"codecs-macos_{ machine } .tar.gz" )
72- else :
73- raise Exception ("Unsupported system: %s" % system )
83+ output_tarball = os .path .join (output_dir , f"codecs-{ get_platform ()} .tar.gz" )
7484
7585for d in [build_dir , output_dir , source_dir ]:
7686 if not os .path .exists (d ):
0 commit comments