diff options
Diffstat (limited to 'tools/openblas_support.py')
-rw-r--r-- | tools/openblas_support.py | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/tools/openblas_support.py b/tools/openblas_support.py index ed43804af..fd8c6a97a 100644 --- a/tools/openblas_support.py +++ b/tools/openblas_support.py @@ -13,13 +13,14 @@ from tempfile import mkstemp, gettempdir from urllib.request import urlopen, Request from urllib.error import HTTPError -OPENBLAS_V = '0.3.21' -OPENBLAS_LONG = 'v0.3.21' +OPENBLAS_V = '0.3.23' +OPENBLAS_LONG = 'v0.3.23' BASE_LOC = 'https://anaconda.org/multibuild-wheels-staging/openblas-libs' BASEURL = f'{BASE_LOC}/{OPENBLAS_LONG}/download' SUPPORTED_PLATFORMS = [ 'linux-aarch64', 'linux-x86_64', + 'musllinux-x86_64', 'linux-i686', 'linux-ppc64le', 'linux-s390x', @@ -55,10 +56,39 @@ def get_ilp64(): def get_manylinux(arch): default = '2014' - ret = os.environ.get("MB_ML_VER", default) + ml_ver = os.environ.get("MB_ML_VER", default) # XXX For PEP 600 this can be a glibc version - assert ret in ('2010', '2014', '_2_24'), f'invalid MB_ML_VER {ret}' - return ret + assert ml_ver in ('2010', '2014', '_2_24'), f'invalid MB_ML_VER {ml_ver}' + suffix = f'manylinux{ml_ver}_{arch}.tar.gz' + return suffix + + +def get_musllinux(arch): + musl_ver = "1_1" + suffix = f'musllinux_{musl_ver}_{arch}.tar.gz' + return suffix + + +def get_linux(arch): + # best way of figuring out whether manylinux or musllinux is to look + # at the packaging tags. If packaging isn't installed (it's not by default) + # fallback to sysconfig (which may be flakier) + try: + from packaging.tags import sys_tags + tags = list(sys_tags()) + plat = tags[0].platform + except ImportError: + # fallback to sysconfig for figuring out if you're using musl + plat = 'manylinux' + # value could be None + v = sysconfig.get_config_var('HOST_GNU_TYPE') or '' + if 'musl' in v: + plat = 'musllinux' + + if 'manylinux' in plat: + return get_manylinux(arch) + elif 'musllinux' in plat: + return get_musllinux(arch) def download_openblas(target, plat, ilp64): @@ -70,8 +100,10 @@ def download_openblas(target, plat, ilp64): '(KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3')} suffix = None if osname == "linux": - ml_ver = get_manylinux(arch) - suffix = f'manylinux{ml_ver}_{arch}.tar.gz' + suffix = get_linux(arch) + typ = 'tar.gz' + elif osname == "musllinux": + suffix = get_musllinux(arch) typ = 'tar.gz' elif plat == 'macosx-x86_64': suffix = 'macosx_10_9_x86_64-gf_c469a42.tar.gz' @@ -200,7 +232,7 @@ def make_init(dirname): ''' Create a _distributor_init.py file for OpenBlas ''' - with open(os.path.join(dirname, '_distributor_init.py'), 'wt') as fid: + with open(os.path.join(dirname, '_distributor_init.py'), 'w') as fid: fid.write(textwrap.dedent(""" ''' Helper to preload windows dlls to prevent dll not found errors. @@ -267,15 +299,11 @@ def test_setup(plats): if not target: raise RuntimeError(f'Could not setup {plat}') print('success with', plat, ilp64) - if osname == 'win': - if not target.endswith('.a'): - raise RuntimeError("Not .a extracted!") - else: - files = glob.glob(os.path.join(target, "lib", "*.a")) - if not files: - raise RuntimeError("No lib/*.a unpacked!") + files = glob.glob(os.path.join(target, "lib", "*.a")) + if not files: + raise RuntimeError("No lib/*.a unpacked!") finally: - if target is not None: + if target: if os.path.isfile(target): os.unlink(target) else: |