(target, plat, ilp64, *, nightly=False)
| 93 | |
| 94 | |
| 95 | def download_openblas(target, plat, ilp64, *, nightly=False): |
| 96 | osname, arch = plat.split("-") |
| 97 | fnsuffix = {None: "", "64_": "64_"}[ilp64] |
| 98 | filename = '' |
| 99 | headers = {'User-Agent': |
| 100 | ('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 ; ' |
| 101 | '(KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3')} |
| 102 | suffix = None |
| 103 | if osname == "linux": |
| 104 | suffix = get_linux(arch) |
| 105 | typ = 'tar.gz' |
| 106 | elif osname == "musllinux": |
| 107 | suffix = get_musllinux(arch) |
| 108 | typ = 'tar.gz' |
| 109 | elif plat == 'macosx-x86_64': |
| 110 | suffix = 'macosx_10_9_x86_64-gf_c469a42.tar.gz' |
| 111 | typ = 'tar.gz' |
| 112 | elif plat == 'macosx-arm64': |
| 113 | suffix = 'macosx_11_0_arm64-gf_5272328.tar.gz' |
| 114 | typ = 'tar.gz' |
| 115 | elif osname == 'win': |
| 116 | if plat == "win-32": |
| 117 | suffix = 'win32-gcc_8_3_0.zip' |
| 118 | else: |
| 119 | suffix = 'win_amd64-gcc_10_3_0.zip' |
| 120 | typ = 'zip' |
| 121 | |
| 122 | if not suffix: |
| 123 | return None |
| 124 | openblas_version = "HEAD" if nightly else OPENBLAS_LONG |
| 125 | filename = ( |
| 126 | f'{BASE_LOC}/{openblas_version}/download/' |
| 127 | f'openblas{fnsuffix}-{openblas_version}-{suffix}' |
| 128 | ) |
| 129 | print(f'Attempting to download {filename}', file=sys.stderr) |
| 130 | req = Request(url=filename, headers=headers) |
| 131 | try: |
| 132 | response = urlopen(req) |
| 133 | except HTTPError: |
| 134 | print(f'Could not download "{filename}"', file=sys.stderr) |
| 135 | raise |
| 136 | length = response.getheader('content-length') |
| 137 | if response.status != 200: |
| 138 | print(f'Could not download "{filename}"', file=sys.stderr) |
| 139 | return None |
| 140 | # print(f"Downloading {length} from {filename}", file=sys.stderr) |
| 141 | data = response.read() |
| 142 | # Verify hash |
| 143 | key = os.path.basename(filename) |
| 144 | # print("Saving to file", file=sys.stderr) |
| 145 | with open(target, 'wb') as fid: |
| 146 | fid.write(data) |
| 147 | return typ |
| 148 | |
| 149 | |
| 150 | def setup_openblas(plat=get_plat(), ilp64=get_ilp64(), nightly=False): |
no test coverage detected