Add PyInstaller Windows release build system.

Frozen builds resolve paths correctly, stage portable onedir output, and zip releases for distribution.
This commit is contained in:
Dr Jones
2026-05-22 19:20:06 -07:00
parent bef3de1245
commit 05a32015db
10 changed files with 548 additions and 24 deletions

View File

@@ -1,25 +1,35 @@
"""
Configuration and constants for GODCWAK.
"""
import os
import json
import shutil
import sys
from pathlib import Path
APP_NAME = "GODCWAK"
APP_VERSION = "1.0"
# Paths
BASE_DIR = Path(__file__).parent
def _is_frozen() -> bool:
return getattr(sys, "frozen", False)
def _exe_dir() -> Path:
return Path(sys.executable).resolve().parent
def _bundle_dir() -> Path:
if _is_frozen() and hasattr(sys, "_MEIPASS"):
return Path(sys._MEIPASS)
return Path(__file__).resolve().parent
# Writable root: next to the exe when frozen, project root in dev
BASE_DIR = _exe_dir() if _is_frozen() else Path(__file__).resolve().parent
BUNDLE_DIR = _bundle_dir()
DATA_DIR = BASE_DIR / "data"
ASSETS_DIR = BASE_DIR / "assets"
# bug #35: removed DATA_DIR.mkdir() side effect from module level.
# Call ensure_dirs() explicitly at startup instead.
def ensure_dirs():
"""Create required application directories. Call once at startup."""
DATA_DIR.mkdir(exist_ok=True)
ASSETS_DIR.mkdir(exist_ok=True)
_assets_bundle = BUNDLE_DIR / "assets"
ASSETS_DIR = _assets_bundle if _assets_bundle.is_dir() else BASE_DIR / "assets"
# Facebook
@@ -69,6 +79,23 @@ DEFAULT_OLLAMA_CONFIG = {
"retry_limit": 3,
}
def ensure_dirs():
"""Create writable dirs and seed default Ollama config for packaged builds."""
DATA_DIR.mkdir(exist_ok=True)
(BASE_DIR / "assets").mkdir(exist_ok=True)
if not OLLAMA_CONFIG_FILE.exists():
bundled = BUNDLE_DIR / "config_ollama.json"
if bundled.is_file():
shutil.copy2(bundled, OLLAMA_CONFIG_FILE)
else:
OLLAMA_CONFIG_FILE.write_text(
json.dumps(DEFAULT_OLLAMA_CONFIG, indent=2),
encoding="utf-8",
)
# GUI Theme Colors
THEME = {
"bg_dark": "#0a0a0f",