@@ -38,9 +38,9 @@ def get_qnn_version() -> str:
3838 return QNN_VERSION
3939
4040
41- def _download_qnn_sdk () -> Optional [pathlib .Path ]:
41+ def _download_qnn_sdk (dst_folder = SDK_DIR ) -> Optional [pathlib .Path ]:
4242 """
43- Download and extract the Qualcomm SDK into SDK_DIR .
43+ Download and extract the Qualcomm SDK into dst_folder .
4444
4545 Notes:
4646 - Only runs on Linux x86 platforms. Skips otherwise.
@@ -53,8 +53,8 @@ def _download_qnn_sdk() -> Optional[pathlib.Path]:
5353 print ("Skipping Qualcomm SDK (only supported on Linux x86)." )
5454 return None
5555
56- SDK_DIR .mkdir (parents = True , exist_ok = True )
57- print (f"SDK_DIR is { SDK_DIR } , exists: { SDK_DIR .exists ()} " )
56+ dst_folder .mkdir (parents = True , exist_ok = True )
57+ print (f"dst_folder is { dst_folder } , exists: { dst_folder .exists ()} " )
5858 print (f"Current working directory: { os .getcwd ()} " )
5959
6060 with tempfile .TemporaryDirectory () as tmpdir :
@@ -95,24 +95,24 @@ def report_progress(block_num, block_size, total_size):
9595
9696 if QAIRT_URL .endswith (".zip" ):
9797 print ("Extracting ZIP archive..." )
98- _extract_zip (archive_path , QAIRT_CONTENT_DIR , SDK_DIR )
98+ _extract_zip (archive_path , QAIRT_CONTENT_DIR , dst_folder )
9999 elif QAIRT_URL .endswith ((".tar.gz" , ".tgz" )):
100100 print ("Extracting TAR archive..." )
101- _extract_tar (archive_path , QAIRT_CONTENT_DIR , SDK_DIR )
101+ _extract_tar (archive_path , QAIRT_CONTENT_DIR , dst_folder )
102102 else :
103103 raise ValueError (f"Unsupported archive format: { QAIRT_URL } " )
104104
105- print (f"Verifying extraction to { SDK_DIR } " )
106- if SDK_DIR .exists ():
105+ print (f"Verifying extraction to { dst_folder } " )
106+ if dst_folder .exists ():
107107 print (f"SDK directory exists. Contents:" )
108- for item in SDK_DIR .iterdir ():
108+ for item in dst_folder .iterdir ():
109109 print (f" { item .name } " )
110110 else :
111111 print ("ERROR: SDK directory was not created!" )
112112
113- print (f"Qualcomm SDK extracted to { SDK_DIR } " )
113+ print (f"Qualcomm SDK extracted to { dst_folder } " )
114114
115- return SDK_DIR
115+ return dst_folder
116116
117117
118118def _extract_zip (archive_path , content_dir , target_dir ):
@@ -166,8 +166,8 @@ def _extract_tar(archive_path: pathlib.Path, prefix: str, target_dir: pathlib.Pa
166166 "libc++.so.1.0" ,
167167 "libc++abi.so.1.0" ,
168168 "libunwind.so.1" ,
169- "libm.so.6" ,
170- "libpython3.10.so.1.0" ,
169+ # "libm.so.6",
170+ # "libpython3.10.so.1.0",
171171]
172172
173173
@@ -189,23 +189,16 @@ def _stage_libcxx(target_dir: pathlib.Path):
189189 with tarfile .open (temp_tar , "r:xz" ) as tar :
190190 tar .extractall (temp_extract .parent )
191191
192- lib_src = temp_extract / "lib"
192+ lib_src = temp_extract / "lib" / "x86_64-unknown-linux-gnu"
193193 for fname in REQUIRED_LIBCXX_LIBS :
194194 src_path = lib_src / fname
195195 if not src_path .exists ():
196- print (f"[libcxx] Warning: { fname } not found in extracted LLVM" )
196+ print (
197+ f"[libcxx] Warning: { fname } not found in extracted LLVM src_path { src_path } "
198+ )
197199 continue
198200 shutil .copy (src_path , target_dir / fname )
199201
200- libcxx = target_dir / "libc++.so.1.0"
201- libcxx_abi = target_dir / "libc++abi.so.1.0"
202- if libcxx .exists ():
203- os .symlink ("libc++.so.1.0" , target_dir / "libc++.so.1" )
204- os .symlink ("libc++.so.1" , target_dir / "libc++.so" )
205- if libcxx_abi .exists ():
206- os .symlink ("libc++abi.so.1.0" , target_dir / "libc++abi.so.1" )
207- os .symlink ("libc++abi.so.1" , target_dir / "libc++abi.so" )
208-
209202 print (f"[libcxx] Staged libc++ to { target_dir } " )
210203
211204
@@ -294,13 +287,14 @@ def _ensure_qnn_sdk_lib() -> bool:
294287
295288
296289def _load_libcxx_libs (lib_path ):
290+ print ("running _load_libcxx_libs" )
297291 candidates = list (lib_path .glob ("*.so*" ))
298292 priority = ["libc++abi" , "libc++" ]
299293 sorted_candidates = [
300294 f for name in priority for f in candidates if f .name .startswith (name )
301295 ]
302296 sorted_candidates += [f for f in candidates if f not in sorted_candidates ]
303-
297+ print ( "sorted_candidates: " , sorted_candidates )
304298 for sofile in sorted_candidates :
305299 try :
306300 ctypes .CDLL (str (sofile ), mode = ctypes .RTLD_GLOBAL )
@@ -357,6 +351,6 @@ def install_qnn_sdk() -> bool:
357351 Returns:
358352 True if both steps succeeded (or were already satisfied), else False.
359353 """
360- ok_qnn = _ensure_qnn_sdk_lib ()
361354 ok_libcxx = _ensure_libcxx_stack ()
355+ ok_qnn = _ensure_qnn_sdk_lib ()
362356 return bool (ok_qnn and ok_libcxx )
0 commit comments