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())