|
6 | 6 | import platform |
7 | 7 | import re |
8 | 8 | import shutil |
| 9 | +import subprocess |
9 | 10 | import sys |
10 | 11 | import tarfile |
11 | 12 | import tempfile |
@@ -36,70 +37,6 @@ def is_linux_x86() -> bool: |
36 | 37 | ) |
37 | 38 |
|
38 | 39 |
|
39 | | -import subprocess |
40 | | - |
41 | | -MINIMUM_LIBC_VERSION = 2.29 |
42 | | - |
43 | | -REQUIRED_LIBC_LIBS = [ |
44 | | - "/lib/x86_64-linux-gnu/libc.so.6", |
45 | | - "/lib64/libc.so.6", |
46 | | - "/lib/libc.so.6", |
47 | | -] |
48 | | - |
49 | | - |
50 | | -def check_glibc_exist_and_validate() -> bool: |
51 | | - """ |
52 | | - Check if users have glibc installed. |
53 | | - """ |
54 | | - exists = False |
55 | | - for path in REQUIRED_LIBC_LIBS: |
56 | | - try: |
57 | | - output = subprocess.check_output( |
58 | | - [path, "--version"], stderr=subprocess.STDOUT |
59 | | - ) |
60 | | - output = output.decode().split("\n")[0] |
61 | | - logger.debug(f"[QNN] glibc version for path {path} is: {output}") |
62 | | - match = re.search(r"version (\d+\.\d+)", output) |
63 | | - if match: |
64 | | - version = match.group(1) |
65 | | - if float(version) >= MINIMUM_LIBC_VERSION: |
66 | | - logger.debug(f"[QNN] glibc version is {version}.") |
67 | | - exists = True |
68 | | - return True |
69 | | - else: |
70 | | - logger.error( |
71 | | - f"[QNN] glibc version is too low. The minimum libc version is {MINIMUM_LIBC_VERSION} Please install glibc following the commands below." |
72 | | - ) |
73 | | - else: |
74 | | - logger.error("[QNN] glibc version not found.") |
75 | | - |
76 | | - except Exception: |
77 | | - continue |
78 | | - |
79 | | - if not exists: |
80 | | - logger.error( |
81 | | - r"""" |
82 | | - [QNN] glibc not found or the version is too low. Please install glibc following the commands below. |
83 | | - Ubuntu/Debian: |
84 | | - sudo apt update |
85 | | - sudo apt install libc6 |
86 | | -
|
87 | | - Fedora/Red Hat: |
88 | | - sudo dnf install glibc |
89 | | -
|
90 | | - Arch Linux: |
91 | | - sudo pacman -S glibc |
92 | | - |
93 | | - Also please make sure the glibc version is >= MINIMUM_LIBC_VERSION. You can verify the glibc version by running the following command: |
94 | | - Option 1: |
95 | | - ldd --version |
96 | | - Option 2: |
97 | | - /path/to/libc.so.6 --version |
98 | | - """ |
99 | | - ) |
100 | | - return exists |
101 | | - |
102 | | - |
103 | 40 | def _download_archive(url: str, archive_path: pathlib.Path) -> bool: |
104 | 41 | """Download archive from URL with progress reporting.""" |
105 | 42 | logger.debug("Archive will be saved to: %s", archive_path) |
@@ -253,6 +190,70 @@ def _extract_tar(archive_path: pathlib.Path, prefix: str, target_dir: pathlib.Pa |
253 | 190 | GLIBC_LIBDIR = GLIBC_ROOT / "lib" |
254 | 191 | GLIBC_REEXEC_GUARD = "QNN_GLIBC_REEXEC" |
255 | 192 |
|
| 193 | +MINIMUM_LIBC_VERSION = 2.29 |
| 194 | + |
| 195 | +GLIBC_CUSTOM = "/tmp/glibc-install-2.29/lib/libc.so.6" |
| 196 | + |
| 197 | +REQUIRED_LIBC_LIBS = [ |
| 198 | + "/lib/x86_64-linux-gnu/libc.so.6", |
| 199 | + "/lib64/libc.so.6", |
| 200 | + "/lib/libc.so.6", |
| 201 | + GLIBC_CUSTOM, |
| 202 | +] |
| 203 | + |
| 204 | + |
| 205 | +def check_glibc_exist_and_validate() -> bool: |
| 206 | + """ |
| 207 | + Check if users have glibc installed. |
| 208 | + """ |
| 209 | + exists = False |
| 210 | + for path in REQUIRED_LIBC_LIBS: |
| 211 | + try: |
| 212 | + output = subprocess.check_output( |
| 213 | + [path, "--version"], stderr=subprocess.STDOUT |
| 214 | + ) |
| 215 | + output = output.decode().split("\n")[0] |
| 216 | + logger.debug(f"[QNN] glibc version for path {path} is: {output}") |
| 217 | + match = re.search(r"version (\d+\.\d+)", output) |
| 218 | + if match: |
| 219 | + version = match.group(1) |
| 220 | + if float(version) >= MINIMUM_LIBC_VERSION: |
| 221 | + logger.debug(f"[QNN] glibc version is {version}.") |
| 222 | + exists = True |
| 223 | + return True |
| 224 | + else: |
| 225 | + logger.error( |
| 226 | + f"[QNN] glibc version is too low. The minimum libc version is {MINIMUM_LIBC_VERSION} Please install glibc following the commands below." |
| 227 | + ) |
| 228 | + else: |
| 229 | + logger.error("[QNN] glibc version not found.") |
| 230 | + |
| 231 | + except Exception: |
| 232 | + continue |
| 233 | + |
| 234 | + if not exists: |
| 235 | + logger.error( |
| 236 | + r"""" |
| 237 | + [QNN] glibc not found or the version is too low. Please install glibc following the commands below. |
| 238 | + Ubuntu/Debian: |
| 239 | + sudo apt update |
| 240 | + sudo apt install libc6 |
| 241 | +
|
| 242 | + Fedora/Red Hat: |
| 243 | + sudo dnf install glibc |
| 244 | +
|
| 245 | + Arch Linux: |
| 246 | + sudo pacman -S glibc |
| 247 | + |
| 248 | + Also please make sure the glibc version is >= MINIMUM_LIBC_VERSION. You can verify the glibc version by running the following command: |
| 249 | + Option 1: |
| 250 | + ldd --version |
| 251 | + Option 2: |
| 252 | + /path/to/libc.so.6 --version |
| 253 | + """ |
| 254 | + ) |
| 255 | + return exists |
| 256 | + |
256 | 257 |
|
257 | 258 | def _check_tmp_glibc() -> bool: |
258 | 259 | """Check if glibc in /tmp was installed correctly and log its version.""" |
|
0 commit comments