5959import  ctypes 
6060import  pathlib 
6161import  functools 
62- import  importlib .resources 
62+ try :
63+     # Python < 3.9 
64+     import  importlib_resources 
65+ except  ImportError :
66+     import  importlib .resources  as  importlib_resources 
6367from  typing  import  (
6468    cast ,
6569    Any ,
7983# Load the library 
8084def  load_shared_library (module_name : str , lib_base_name : str ):
8185    # Construct the paths to the possible shared library names 
82-     base_path  =  pathlib .Path (__file__ ).parent .resolve ()
86+     base_path  =  pathlib .Path (__file__ ).parent .resolve ()  /   "lib" 
8387    # Searching for the library in the current directory under the name "libggml" (default name 
8488    # for ggml) and "ggml" (default name for this repo) 
8589    lib_names : List [str ] =  [
@@ -92,7 +96,8 @@ def load_shared_library(module_name: str, lib_base_name: str):
9296
9397    for  lib_name  in  lib_names :
9498        try :
95-             with  importlib .resources .path (module_name , lib_name ) as  p :
99+             with  importlib_resources .as_file (importlib_resources .files (module_name ).joinpath ("lib" , lib_name )) as  p : # type: ignore 
100+                 p  =  cast (pathlib .Path , p )
96101                if  os .path .exists (p ):
97102                    path  =  p 
98103                    break 
@@ -107,6 +112,7 @@ def load_shared_library(module_name: str, lib_base_name: str):
107112    cdll_args  =  dict ()  # type: ignore 
108113    # Add the library directory to the DLL search path on Windows (if needed) 
109114    if  sys .platform  ==  "win32"  and  sys .version_info  >=  (3 , 8 ):
115+         os .environ ["PATH" ] =  str (base_path ) +  os .pathsep  +  os .environ ["PATH" ]
110116        os .add_dll_directory (str (base_path ))
111117        cdll_args ["winmode" ] =  0 
112118
@@ -7752,7 +7758,7 @@ class gguf_init_params(ctypes.Structure):
77527758
77537759    if  TYPE_CHECKING :
77547760        no_alloc : bool 
7755-         ctx : ggml_context_p 
7761+         ctx : CtypesPointer [ ggml_context_p ] 
77567762
77577763    _fields_  =  [
77587764        ("no_alloc" , ctypes .c_bool ),
0 commit comments