# Path: blaspy/errors.py
# def raise_blas_os_error():
#     raise RuntimeError("BLASpy does not have a bundled BLAS implementation appropriate for "
#                        "your operating system. Please download and compile one, "
#                        "such as OpenBLAS, then modify config.py to point to that BLAS "
#                        "implementation.")


from .errors import raise_blas_os_error
from ctypes import cdll
from os import chdir, path
from platform import system
from struct import calcsize
# or if your operating system is not supported by BLASpy out of the box.
BLAS_NAME = ""  # default is ""

# True if the BLAS .so or .dll file is in the blaspy/lib subdirectory,
# False if Python should search for it.
IN_BLASPY_SUBDIRECTORY = True  # default is True

###############################
# DO NOT EDIT BELOW THIS LINE #
###############################

# find the appropriate BLAS to use
if BLAS_NAME == "":  # try to use included OpenBLAS
    PREPEND = str(path.dirname(__file__))[:-6] + "lib/"
    if system() == "Windows":
        if calcsize("P") == 8:  # 64-bit
            BLAS_NAME = "libopenblas-0.2.13-win64-int32.dll"
            chdir(PREPEND + "win64")
        else:  # 32-bit
            BLAS_NAME = "libopenblas-0.2.13-win32.dll"
            chdir(PREPEND + "win32")
        PREPEND = ""
    elif system() == "Linux":
        if calcsize("P") == 8:  # 64-bit
            BLAS_NAME = "libopenblas-0.2.13-linux64.so"
            PREPEND += "linux64/"
        else:  # 32-bit
            BLAS_NAME = "libopenblas-0.2.13-linux32.so"
            PREPEND += "linux32/"
    else:  # no appropriate OpenBLAS included, BLAS_NAME_OVERRIDE must be used

# Path: blaspy/errors.py
# def raise_blas_os_error():
#     raise RuntimeError("BLASpy does not have a bundled BLAS implementation appropriate for "
#                        "your operating system. Please download and compile one, "
#                        "such as OpenBLAS, then modify config.py to point to that BLAS "
#                        "implementation.")


# Path: blaspy/config.py
from .errors import raise_blas_os_error
from ctypes import cdll
from os import chdir, path
from platform import system
from struct import calcsize

# or if your operating system is not supported by BLASpy out of the box.
BLAS_NAME = ""  # default is ""

# True if the BLAS .so or .dll file is in the blaspy/lib subdirectory,
# False if Python should search for it.
IN_BLASPY_SUBDIRECTORY = True  # default is True

###############################
# DO NOT EDIT BELOW THIS LINE #
###############################

# find the appropriate BLAS to use
if BLAS_NAME == "":  # try to use included OpenBLAS
    PREPEND = str(path.dirname(__file__))[:-6] + "lib/"
    if system() == "Windows":
        if calcsize("P") == 8:  # 64-bit
            BLAS_NAME = "libopenblas-0.2.13-win64-int32.dll"
            chdir(PREPEND + "win64")
        else:  # 32-bit
            BLAS_NAME = "libopenblas-0.2.13-win32.dll"
            chdir(PREPEND + "win32")
        PREPEND = ""
    elif system() == "Linux":
        if calcsize("P") == 8:  # 64-bit
            BLAS_NAME = "libopenblas-0.2.13-linux64.so"
            PREPEND += "linux64/"
        else:  # 32-bit
            BLAS_NAME = "libopenblas-0.2.13-linux32.so"
            PREPEND += "linux32/"
    else:  # no appropriate OpenBLAS included, BLAS_NAME_OVERRIDE must be used

        raise_blas_os_error()