#!/usr/bin/env python3
"""Development entry point; installed wheels use the same Python CLI."""
import os
from pathlib import Path
import stat
import sys

root = Path(__file__).absolute().parent.parent
if sys.platform == 'linux':
    owners = {0} if os.geteuid() == 0 else {0, os.geteuid()}
    for path in (root, *root.parents):
        info = path.lstat()
        sticky = info.st_uid == 0 and info.st_mode & stat.S_ISVTX
        if stat.S_ISLNK(info.st_mode) or info.st_uid not in owners or info.st_mode & 0o022 and not sticky:
            print('mihomoctl: source runtime is not trusted; install into a protected directory', file=sys.stderr)
            raise SystemExit(2)
sys.path.insert(0, str(root))
from mihomoctl.cli import main
raise SystemExit(main())
