From abc611e4de2954ab3605547be88ade563564a3f2 Mon Sep 17 00:00:00 2001 From: puke <1129090915@qq.com> Date: Sun, 9 Nov 2025 21:05:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89PI?= =?UTF-8?q?XELLE=5FVIDEO=5FROOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packaging/windows/templates/start.bat | 3 +++ packaging/windows/templates/start_api.bat | 3 +++ packaging/windows/templates/start_web.bat | 3 +++ pixelle_video/utils/os_util.py | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packaging/windows/templates/start.bat b/packaging/windows/templates/start.bat index cbfda16..84f4cff 100644 --- a/packaging/windows/templates/start.bat +++ b/packaging/windows/templates/start.bat @@ -18,6 +18,9 @@ cd /d "%PROJECT_ROOT%" :: Set PYTHONPATH to project root for module imports set "PYTHONPATH=%PROJECT_ROOT%" +:: Set PIXELLE_VIDEO_ROOT environment variable for reliable path resolution +set "PIXELLE_VIDEO_ROOT=%PROJECT_ROOT%" + :: Start Web UI echo [Starting] Launching Pixelle-Video Web UI... echo Browser will open at: http://localhost:8501 diff --git a/packaging/windows/templates/start_api.bat b/packaging/windows/templates/start_api.bat index 735cbcb..771c2cb 100644 --- a/packaging/windows/templates/start_api.bat +++ b/packaging/windows/templates/start_api.bat @@ -18,6 +18,9 @@ cd /d "%PROJECT_ROOT%" :: Set PYTHONPATH to project root for module imports set "PYTHONPATH=%PROJECT_ROOT%" +:: Set PIXELLE_VIDEO_ROOT environment variable for reliable path resolution +set "PIXELLE_VIDEO_ROOT=%PROJECT_ROOT%" + :: Start API Server echo [Starting] Launching Pixelle-Video API Server... echo API will be available at: http://localhost:8000 diff --git a/packaging/windows/templates/start_web.bat b/packaging/windows/templates/start_web.bat index aa052b9..d310e18 100644 --- a/packaging/windows/templates/start_web.bat +++ b/packaging/windows/templates/start_web.bat @@ -18,6 +18,9 @@ cd /d "%PROJECT_ROOT%" :: Set PYTHONPATH to project root for module imports set "PYTHONPATH=%PROJECT_ROOT%" +:: Set PIXELLE_VIDEO_ROOT environment variable for reliable path resolution +set "PIXELLE_VIDEO_ROOT=%PROJECT_ROOT%" + :: Start Web UI (Standalone mode) echo [Starting] Launching Pixelle-Video Web UI (Standalone)... echo Browser will open at: http://localhost:8501 diff --git a/pixelle_video/utils/os_util.py b/pixelle_video/utils/os_util.py index 1b22c59..3538f7e 100644 --- a/pixelle_video/utils/os_util.py +++ b/pixelle_video/utils/os_util.py @@ -26,11 +26,21 @@ from typing import Optional, Tuple, Literal def get_pixelle_video_root_path() -> str: """ - Get Pixelle-Video root path - current working directory + Get Pixelle-Video root path + + Uses PIXELLE_VIDEO_ROOT environment variable to determine project root. + This ensures reliable path resolution in both development and packaged environments. Returns: - Current working directory as string + Project root path as string """ + # Check environment variable (required for reliable operation) + env_root = os.environ.get("PIXELLE_VIDEO_ROOT") + if env_root and Path(env_root).exists(): + return str(Path(env_root).resolve()) + + # Fallback to current working directory if environment variable not set + # (for development environments where env var might not be set) return str(Path.cwd())