Skip to content

Commit 72f3bc7

Browse files
committed
solve qualcomm import issue
1 parent be3c353 commit 72f3bc7

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

setup.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
# imports.
5353
import logging
5454
import os
55+
import platform
5556
import re
5657
import shutil
5758
import site
@@ -92,6 +93,23 @@ def _is_windows() -> bool:
9293
return sys.platform == "win32"
9394

9495

96+
# Duplicate of the one in backends.qualcomm.scripts.download_qnn_sdk to avoid
97+
# import errors.
98+
def is_linux_x86() -> bool:
99+
"""
100+
Check if the current platform is Linux x86_64.
101+
102+
Returns:
103+
bool: True if the system is Linux x86_64, False otherwise.
104+
"""
105+
return platform.system().lower() == "linux" and platform.machine().lower() in (
106+
"x86_64",
107+
"amd64",
108+
"i386",
109+
"i686",
110+
)
111+
112+
95113
class Version:
96114
"""Static strings that describe the version of the pip package."""
97115

@@ -465,8 +483,6 @@ def run(self):
465483

466484
try:
467485
# Following code is for building the Qualcomm backend.
468-
from backends.qualcomm.scripts.download_qnn_sdk import is_linux_x86
469-
470486
if is_linux_x86():
471487
os.environ["EXECUTORCH_BUILDING_WHEEL"] = "1"
472488
from backends.qualcomm.scripts.download_qnn_sdk import _download_qnn_sdk
@@ -535,8 +551,8 @@ def run(self):
535551
self.copy_file(str(so_src), str(so_dst))
536552
logging.info(f"Copied Qualcomm backend: {so_src} -> {so_dst}")
537553

538-
except ImportError as e:
539-
logging.error(f"Fail to build Qualcomm backend: {e}")
554+
except ImportError:
555+
logging.error(f"Fail to build Qualcomm backend")
540556
logging.exception("Import error")
541557

542558
if self.editable_mode:

0 commit comments

Comments
 (0)