1010from pathlib import Path
1111from typing import Iterator
1212
13- from ._logger import logger
1413from .defines import is_arch_x86
1514from .version import ARRAYFIRE_VER_MAJOR
1615
16+ VERBOSE_LOADS = os .environ .get ("AF_VERBOSE_LOADS" , "" ) == "1"
17+
1718
1819class _LibPrefixes (Enum ):
1920 forge = ""
@@ -120,10 +121,6 @@ def __iter__(self) -> Iterator:
120121
121122class Backend :
122123 _backend_type : BackendType
123- # HACK for osx
124- # _backend.clib = ctypes.CDLL("/opt/arrayfire//lib/libafcpu.3.dylib")
125- # HACK for windows
126- # _backend.clib = ctypes.CDLL("C:/Program Files/ArrayFire/v3/lib/afcpu.dll")
127124 _clib : ctypes .CDLL
128125
129126 def __init__ (self ) -> None :
@@ -136,18 +133,21 @@ def _load_forge_lib(self) -> None:
136133 for lib_name in self ._lib_names ("forge" , _LibPrefixes .forge ):
137134 try :
138135 ctypes .cdll .LoadLibrary (str (lib_name ))
139- logger .info (f"Loaded { lib_name } " )
136+ if VERBOSE_LOADS :
137+ print (f"Loaded { lib_name } " )
140138 break
141139 except OSError :
142- logger .warning (f"Unable to load { lib_name } " )
140+ if VERBOSE_LOADS :
141+ print (f"Unable to load { lib_name } " )
143142 pass
144143
145144 def _load_backend_libs (self ) -> None :
146145 for backend_type in BackendType :
147146 self ._load_backend_lib (backend_type )
148147
149148 if self ._backend_type :
150- logger .info (f"Setting { backend_type .name } as backend." )
149+ if VERBOSE_LOADS :
150+ print (f"Setting { backend_type .name } as backend." )
151151 break
152152
153153 if not self ._backend_type and not self ._clib :
@@ -169,19 +169,23 @@ def _load_backend_lib(self, _backend_type: BackendType) -> None:
169169 if _backend_type == BackendType .cuda :
170170 self ._load_nvrtc_builtins_lib (lib_name .parent )
171171
172- logger .info (f"Loaded { lib_name } " )
172+ if VERBOSE_LOADS :
173+ print (f"Loaded { lib_name } " )
173174 break
174175 except OSError :
175- logger .warning (f"Unable to load { lib_name } " )
176+ if VERBOSE_LOADS :
177+ print (f"Unable to load { lib_name } " )
176178 pass
177179
178180 def _load_nvrtc_builtins_lib (self , lib_path : Path ) -> None :
179181 nvrtc_name = self ._find_nvrtc_builtins_lib_name (lib_path )
180182 if nvrtc_name :
181183 ctypes .cdll .LoadLibrary (str (lib_path / nvrtc_name ))
182- logger .info (f"Loaded { lib_path / nvrtc_name } " )
184+ if VERBOSE_LOADS :
185+ print (f"Loaded { lib_path / nvrtc_name } " )
183186 else :
184- logger .warning ("Could not find local nvrtc-builtins library" )
187+ if VERBOSE_LOADS :
188+ print ("Could not find local nvrtc-builtins library" )
185189
186190 def _lib_names (self , name : str , lib : _LibPrefixes , ver_major : str | None = None ) -> list [Path ]:
187191 post = self ._backend_path_config .lib_postfix if ver_major is None else ver_major
0 commit comments