<commit_before>import os
import sys
import glob
import shutil
import textwrap
import platform

from tempfile import mkstemp, gettempdir
from urllib.request import urlopen
from urllib.error import HTTPError
import zipfile
import tarfile

OPENBLAS_V = 'v0.3.8'
OPENBLAS_LONG = 'v0.3.5-605-gc815b8fb'  # the 0.3.5 is misleading
BASE_LOC = ''
RACKSPACE = 'https://3f23b170c54c2533c070-1c8a9b3114517dc5fe17b7c3f8c63a43.ssl.cf2.rackcdn.com'
ARCHITECTURES = ['', 'windows', 'darwin', 'aarch64', 'x86', 'ppc64le', 's390x']

IS_32BIT = sys.maxsize < 2**32
def get_arch():
    if platform.system() == 'Windows':
        ret = 'windows'
    elif platform.system() == 'Darwin':
        ret = 'darwin'
    elif 'x86' in platform.uname().machine:
        # What do 32 bit machines report?
        # If they are a docker, they report x86_64
        ret = 'x86'
    else:
        ret = platform.uname().machine
    assert ret in ARCHITECTURES
    return ret

def get_ilp64():
    if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0":
        return None
    if IS_32BIT:
        raise RuntimeError("NPY_USE_BLAS_ILP64 set on 32-bit arch")
    return "64_"

def download_openblas(target, arch, ilp64):
    fnsuffix = {None: "", "64_": "64_"}[ilp64]
    filename = ''
    if arch in ('aarch64', 'ppc64le', 's390x'):
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-manylinux2014_{arch}'
        typ = 'tar.gz'
        typ = 'tar.gz'
    elif arch == 'darwin':
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-macosx_10_9_x86_64-gf_1becaaa.tar.gz'
        typ = 'tar.gz'
    elif arch == 'windows':
        if IS_32BIT:
            suffix = 'win32-gcc_7_1_0.zip'
        else:
            suffix = 'win_amd64-gcc_7_1_0.zip'
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
        typ = 'zip'
    elif 'x86' in arch:
        if IS_32BIT:
            suffix = 'manylinux1_i686.tar.gz'
        else:
            suffix = 'manylinux1_x86_64.tar.gz'
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
        typ = 'tar.gz'
    if not filename:
        return None
    print("Downloading:", filename, file=sys.stderr)
    try:
        with open(target, 'wb') as fid:
            fid.write(urlopen(filename).read())
    except HTTPError:
        print(f'Could not download "{filename}"')
        return None
    return typ

def setup_openblas(arch=get_arch(), ilp64=get_ilp64()):
    '''
    Download and setup an openblas library for building. If successful,<commit_msg>Made changes to openblas_support.py<commit_after>import os
import sys
import glob
import shutil
import textwrap
import platform

from tempfile import mkstemp, gettempdir
from urllib.request import urlopen
from urllib.error import HTTPError
import zipfile
import tarfile

OPENBLAS_V = 'v0.3.8'
OPENBLAS_LONG = 'v0.3.5-605-gc815b8fb'  # the 0.3.5 is misleading
BASE_LOC = ''
RACKSPACE = 'https://3f23b170c54c2533c070-1c8a9b3114517dc5fe17b7c3f8c63a43.ssl.cf2.rackcdn.com'
ARCHITECTURES = ['', 'windows', 'darwin', 'aarch64', 'x86', 'ppc64le', 's390x']

IS_32BIT = sys.maxsize < 2**32
def get_arch():
    if platform.system() == 'Windows':
        ret = 'windows'
    elif platform.system() == 'Darwin':
        ret = 'darwin'
    elif 'x86' in platform.uname().machine:
        # What do 32 bit machines report?
        # If they are a docker, they report x86_64
        ret = 'x86'
    else:
        ret = platform.uname().machine
    assert ret in ARCHITECTURES
    return ret

def get_ilp64():
    if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0":
        return None
    if IS_32BIT:
        raise RuntimeError("NPY_USE_BLAS_ILP64 set on 32-bit arch")
    return "64_"

def download_openblas(target, arch, ilp64):
    MAC_VERSION = 'macosx_10_9_x86_64-gf_1becaaa.tar.gz'
    fnsuffix = {None: "", "64_": "64_"}[ilp64]
    filename = ''
    if arch in ('aarch64', 'ppc64le', 's390x'):
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-manylinux2014_{arch}'
        typ = 'tar.gz'
        typ = 'tar.gz'
    elif arch == 'darwin':
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-{MAC_VERSION}'
        typ = 'tar.gz'
    elif arch == 'windows':
        if IS_32BIT:
            suffix = 'win32-gcc_7_1_0.zip'
        else:
            suffix = 'win_amd64-gcc_7_1_0.zip'
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
        typ = 'zip'
    elif 'x86' in arch:
        if IS_32BIT:
            suffix = 'manylinux1_i686.tar.gz'
        else:
            suffix = 'manylinux1_x86_64.tar.gz'
        filename = f'{RACKSPACE}/openblas{fnsuffix}-{OPENBLAS_LONG}-{suffix}'
        typ = 'tar.gz'
    if not filename:
        return None
    print("Downloading:", filename, file=sys.stderr)
    try:
        with open(target, 'wb') as fid:
            fid.write(urlopen(filename).read())
    except HTTPError:
        print(f'Could not download "{filename}"')
        return None
    return typ

def setup_openblas(arch=get_arch(), ilp64=get_ilp64()):
    '''
    Download and setup an openblas library for building. If successful,
{'fraction_non_alphanumeric': 0.12889408099688474, 'fraction_numerical': 0.05685358255451713, 'mean_word_length': 2.885779122541604, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4521999', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1903, 'n_words': 412}