1) set the required textual version to version 8.2.8
2) generated installers which bundle the required .venv
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""Resolve where the application's own files live at runtime.
|
||||
|
||||
Three ways this app can run, all needing the *same* relative layout
|
||||
(``i18n/<lang>/...`` and ``app/styles.tcss`` next to ``main.py``) to be
|
||||
discoverable as real files on disk:
|
||||
|
||||
* **Plain source checkout** — ``python main.py``. Everything is exactly
|
||||
where it looks in this repository.
|
||||
* **PyInstaller onefile build** — the interpreter, bundled packages and
|
||||
``--add-data`` files are unpacked into a temporary directory at startup,
|
||||
exposed as ``sys._MEIPASS``. Pure-Python modules (like this one) run
|
||||
from a synthetic, non-existent path, but explicitly added data files
|
||||
(``i18n/`` and ``app/styles.tcss``) are real files under ``_MEIPASS``.
|
||||
* **pex zipapp** — pex extracts its bundled sources to a cache directory
|
||||
on first run and imports them from there, so ``__file__``-based
|
||||
resolution behaves exactly like the plain source checkout.
|
||||
|
||||
:func:`bundle_root` returns the single directory to resolve both cases
|
||||
against, so callers don't need to know which one they're running under.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def is_frozen() -> bool:
|
||||
"""True inside a PyInstaller-built executable."""
|
||||
return bool(getattr(sys, "frozen", False))
|
||||
|
||||
|
||||
def bundle_root() -> Path:
|
||||
"""Directory that contains ``i18n/`` and ``app/`` at runtime."""
|
||||
if is_frozen():
|
||||
meipass = getattr(sys, "_MEIPASS", None)
|
||||
if meipass:
|
||||
return Path(meipass)
|
||||
# Onedir builds without _MEIPASS (shouldn't normally happen with
|
||||
# the bundled spec, but fall back to the executable's directory).
|
||||
return Path(sys.executable).resolve().parent
|
||||
|
||||
# Plain source checkout or a pex zipapp: this file lives at
|
||||
# <project_root>/app/runtime_paths.py.
|
||||
return Path(__file__).resolve().parent.parent
|
||||
+6
-1
@@ -14,6 +14,7 @@ from i18n import I18n
|
||||
|
||||
from . import ffmpeg_client, ytdlp_client
|
||||
from .models import FormatEntry, VideoInfo
|
||||
from .runtime_paths import bundle_root
|
||||
from .screens import ErrorScreen, FormatSelectScreen, HelpScreen, LanguageSelectScreen
|
||||
|
||||
|
||||
@@ -22,7 +23,11 @@ class DownloadManagerApp(App[None]):
|
||||
|
||||
# All widget styling (this screen plus every modal screen) lives in one
|
||||
# external stylesheet rather than scattered DEFAULT_CSS/CSS blocks.
|
||||
CSS_PATH = "styles.tcss"
|
||||
# Resolved via bundle_root() rather than a plain relative path so it
|
||||
# keeps working from a PyInstaller build, where this module's __file__
|
||||
# is a synthetic path Textual can't open() directly — see
|
||||
# runtime_paths.py.
|
||||
CSS_PATH = str(bundle_root() / "app" / "styles.tcss")
|
||||
|
||||
# `priority=True` makes these global: they fire even while an Input (or
|
||||
# any other widget with its own key bindings, e.g. Input's built-in
|
||||
|
||||
Reference in New Issue
Block a user