#!/usr/bin/python3.13
# -*- coding: utf-8 -*-
import re
import sys
import os
from os.path import dirname, normpath, realpath

LAUNCH_PATH = dirname(realpath(__file__))

# Prevent loading Python modules from home folder
# They can interfere with Lutris and prevent it
# from working.
sys.path = [path for path in sys.path if not path.startswith("/home")
            and not path.startswith("/var/home")]

if os.path.isdir(os.path.join(LAUNCH_PATH, "../src/pkgupdates")):
    sys.dont_write_bytecode = True
    SOURCE_PATH = normpath(os.path.join(LAUNCH_PATH, "../src"))
    sys.path.insert(0, SOURCE_PATH)
else:
    sys.path.insert(0, os.path.normpath(os.path.join(LAUNCH_PATH,
                                        "../lib/pkgupdates")))

try:
    from pkgupdates import main
except ImportError as ex:
    sys.stderr.write(f"Error importing pkgupdates module: {ex}\n")
    sys.exit(1)

sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(main())
