Download src/codex_dashboard/bootstrap.py from smlflg/CodexDashBoard: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/smlflg/CodexDashBoard/resolve/main/src/codex_dashboard/bootstrap.py
- Command line
-
hf download hf://smlflg/CodexDashBoard/src/codex_dashboard/bootstrap.py
-
curl -L -o bootstrap.py https://huggingface.co/smlflg/CodexDashBoard/resolve/main/src/codex_dashboard/bootstrap.py
1.2 kB
| from __future__ import annotations | |
| import sys | |
| from collections.abc import Callable | |
| GUI_SYSTEM_PACKAGES = ( | |
| "libgirepository-2.0-dev", | |
| "gobject-introspection", | |
| "libgtk-3-dev", | |
| "libcairo2-dev", | |
| "pkg-config", | |
| ) | |
| def format_missing_gi_message() -> str: | |
| packages = " ".join(GUI_SYSTEM_PACKAGES) | |
| return ( | |
| "CodexDashBoard needs PyGObject / GTK to start.\n" | |
| "Install Ubuntu/Pop!_OS system packages:\n" | |
| f" sudo apt-get install -y {packages}\n" | |
| "Then install the Python GUI extra:\n" | |
| " python3 -m pip install -e '.[gui]'" | |
| ) | |
| def run(app_main_loader: Callable[[], Callable[[], int]] | None = None, *, err=None) -> int: | |
| err = sys.stderr.write if err is None else err | |
| app_main_loader = load_app_main if app_main_loader is None else app_main_loader | |
| try: | |
| app_main = app_main_loader() | |
| except ImportError as exc: | |
| text = str(exc) | |
| if "gi" in text or "Gtk" in text or "Gdk" in text or "Ayatana" in text: | |
| err(format_missing_gi_message() + "\n") | |
| return 1 | |
| raise | |
| return app_main() | |
| def load_app_main() -> Callable[[], int]: | |
| from .app import main | |
| return main |