Files
computer-playbook/cli/__main__.py
T
kevinveenbirkenbach b334a5c98d fix(cli): ensure project root on sys.path when running cli/__main__.py directly
- Prevent accidental import of installed "cli" package from site-packages
- Make `python3 cli/__main__.py ...` behave identical to `python -m cli ...`
- Add env.development to .dockerignore to match .gitignore

https://chatgpt.com/share/69720fd6-a1c8-800f-b1e2-6909aa63643a
2026-01-22 13:13:01 +01:00

21 lines
563 B
Python
Executable File

#!/usr/bin/env python3
from __future__ import annotations
import sys
from pathlib import Path
# Ensure project root is on sys.path when executing this file directly:
# python3 cli/__main__.py ...
#
# Without this, sys.path[0] points to "<root>/cli", and importing "cli.*"
# may accidentally resolve to an installed package from site-packages.
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from cli.core.app import main # noqa: E402
if __name__ == "__main__":
main()