#!/usr/bin/env python3

"""
Openage can, and should, be launched via python3 -m openage.

However, for dynamic analysis using LLVM's sanitizer, a self-compiled
executable is needed.

This file is Cythonized with an embedded interpreter, producing ./run,
which satisifies that requirement.
"""

if __name__ == '__main__':
    # This is stupid but without it, Cython/Python cannot find the openage module.
    import multiprocessing
    import os
    import site
    import sys
    sys.path.append(os.getcwd())

    # This binary embeds the base Python interpreter, which doesn't know about
    # the virtual environment openage may have been configured with.
    # Make the packages of the configured interpreter importable:
    site.addsitedir("/usr/lib/python3.14/site-packages")

    # multiprocessing can't start worker processes by launching this binary,
    # so let it launch the configured interpreter instead:
    multiprocessing.set_executable("/usr/sbin/python3.14")

    from openage.__main__ import main
    main()
else:
    print("Running this in the source directory is not supported.",
          "Please use `make run` or `bin/run.py` to start instead.")
