From 141c22e2214b8e9b97015fa8e2bbf5d892bf470f Mon Sep 17 00:00:00 2001 From: quic-zhanweiw Date: Fri, 20 Dec 2024 21:24:51 +0800 Subject: [PATCH] Support Linux --- samples/python/utils/install.py | 2 +- script/qai_appbuilder/__init__.py | 6 ++++++ script/qai_appbuilder/qnncontext.py | 4 +--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/python/utils/install.py b/samples/python/utils/install.py index 7cf2549..7917042 100644 --- a/samples/python/utils/install.py +++ b/samples/python/utils/install.py @@ -124,7 +124,7 @@ def update_progress(self, block_num=1, block_size=1, total_size=None): def download_url_pywget(url, filepath, desc=None, fail=None): ret = True - # Disable warning for insecure request since we set 'verify=False'. + # Create an unverified SSLContext - a context with disables all certificate verification. import ssl ssl._create_default_https_context = ssl._create_unverified_context diff --git a/script/qai_appbuilder/__init__.py b/script/qai_appbuilder/__init__.py index 3c7b367..ae96085 100644 --- a/script/qai_appbuilder/__init__.py +++ b/script/qai_appbuilder/__init__.py @@ -5,5 +5,11 @@ # SPDX-License-Identifier: BSD-3-Clause # #============================================================================= +import os +import sys +g_base_path = os.path.dirname(os.path.abspath(__file__)) +if sys.platform.startswith('linux'): + import ctypes + ctypes.CDLL(g_base_path + "/libappbuilder.so", ctypes.RTLD_GLOBAL) from .qnncontext import * diff --git a/script/qai_appbuilder/qnncontext.py b/script/qai_appbuilder/qnncontext.py index 0ecb2f5..1ceb304 100644 --- a/script/qai_appbuilder/qnncontext.py +++ b/script/qai_appbuilder/qnncontext.py @@ -10,15 +10,13 @@ import sys import functools import time -import platform from qai_appbuilder import appbuilder -machine = platform.machine() QNN_SYSTEM_LIB = "QnnSystem.dll" QNN_LIB_EXT = ".dll" QNN_LIB_PRE = "" PATH_SLASH = "\\" -if machine == "aarch64": # linux +if sys.platform.startswith('linux'): QNN_SYSTEM_LIB = "libQnnSystem.so" QNN_LIB_EXT = ".so" QNN_LIB_PRE = "lib"