Пример #1
0
def get_lib_suffix():

    def walk_ld_library_path():
        if IS_WIN:
            ld_library_path = os.environ.get('LIBRARY_LIB')
            if ld_library_path is None:
                ld_library_path = f"{os.environ.get('CONDA_PREFIX')}/Library/lib"
        else:
            ld_library_path = os.environ.get('LD_LIBRARY_PATH', None)

        if ld_library_path is None:
            return None

        libs = []
        if IS_WIN:
            ld_library_path = ld_library_path.split(';')
        else:
            ld_library_path = ld_library_path.split(':')
        while '' in ld_library_path:
            ld_library_path.remove('')
        for lib_path in ld_library_path:
            for _, _, new_files in os.walk(lib_path):
                libs += new_files

        for lib in libs:
            if 'onedal_core' in lib:
                return 'onedal'
            if 'daal_core' in lib:
                return 'daal'
        return None

    def walk_libdir():
        global lib_dir

        for _, _, libs in os.walk(lib_dir):
            for lib in libs:
                if 'onedal_core' in lib:
                    return 'onedal'
                if 'daal_core' in lib:
                    return 'daal'
        return None

    ld_lib_path_suffix = walk_ld_library_path()
    lib_dir_suffix = walk_libdir()
    if find_library('onedal_core') is not None or \
       ld_lib_path_suffix == 'onedal' or \
            lib_dir_suffix == 'onedal':
        return 'onedal'
    if find_library('daal_core') is not None or \
       ld_lib_path_suffix == 'daal' or \
            lib_dir_suffix == 'daal':
        return 'daal'

    raise ImportError('Unable to import oneDAL or oneDAL lib')
Пример #2
0
def get_win_major_version():
    lib_name = find_library('onedal_core')
    if lib_name is None:
        return ''
    version = lib_name.split('\\')[-1].split('.')[1]
    try:
        version = '.' + str(int(version))
    except ValueError:
        version = ''
    return version