|
1 | | -from dataclasses import dataclass |
2 | | -from pathlib import Path |
3 | | -from typing import Optional, Tuple |
4 | | -from collections.abc import MutableMapping |
5 | | -import zipfile |
| 1 | +import re |
| 2 | + |
6 | 3 | import distro |
| 4 | +import glfw |
7 | 5 | import logging |
8 | 6 | import os |
9 | 7 | import psutil |
|
13 | 11 | import subprocess |
14 | 12 | import sys |
15 | 13 | import time |
| 14 | +import zipfile |
| 15 | + |
| 16 | +from collections.abc import MutableMapping |
| 17 | +from dataclasses import dataclass |
| 18 | +from packaging.version import Version |
| 19 | +from pathlib import Path |
| 20 | +from typing import Optional, Tuple |
16 | 21 |
|
17 | 22 | from ou_dedetai import constants, network |
18 | 23 | from ou_dedetai.app import App |
19 | 24 |
|
20 | 25 |
|
21 | | -def fix_ld_library_path(env: Optional[MutableMapping[str, str]]) -> dict[str, str]: |
| 26 | +def fix_ld_library_path(env: Optional[MutableMapping[str, str]]) -> dict[str, str]: |
22 | 27 | """Removes pyinstaller bundled dynamic linked libraries when executing commands |
23 | 28 |
|
24 | 29 | - https://pyinstaller.org/en/latest/common-issues-and-pitfalls.html#launching-external-programs-from-the-frozen-application |
@@ -366,6 +371,33 @@ class SuperuserCommandNotFound(Exception): |
366 | 371 | """Superuser command not found. Install pkexec or sudo or doas""" |
367 | 372 |
|
368 | 373 |
|
| 374 | +def get_opengl_version(required_version="3.2"): |
| 375 | + try: |
| 376 | + result = subprocess.run(['glxinfo'], capture_output=True, text=True, check=True) |
| 377 | + except FileNotFoundError: |
| 378 | + return False, "glxinfo command not found. Please install mesa-utils or equivalent." |
| 379 | + except subprocess.CalledProcessError as e: |
| 380 | + return False, f"glxinfo command failed: {e.stderr.strip()}" |
| 381 | + |
| 382 | + match = re.search(r"OpenGL version string:\s+([\d\.]+)", result.stdout) |
| 383 | + if not match: |
| 384 | + return False, "Failed to parse OpenGL version from glxinfo output." |
| 385 | + |
| 386 | + opengl_version = match.group(1) |
| 387 | + if Version(opengl_version) >= Version(required_version): |
| 388 | + message = f"OpenGL Version: {opengl_version} is supported (>= {required_version})." |
| 389 | + logging.info(message) |
| 390 | + return True, message |
| 391 | + else: |
| 392 | + message = f"OpenGL Version: {opengl_version} is not supported (must be >= {required_version})." |
| 393 | + logging.info(message) |
| 394 | + return False, message |
| 395 | + |
| 396 | + |
| 397 | +class OpenGLIncompatible(Exception): |
| 398 | + """Superuser command not found. Install pkexec or sudo or doas""" |
| 399 | + |
| 400 | + |
369 | 401 | def get_superuser_command() -> str: |
370 | 402 | if shutil.which('pkexec'): |
371 | 403 | return "pkexec" |
|
0 commit comments