32 lines
867 B
Python
32 lines
867 B
Python
"""Compatibility entry point for retained Valve Proton 7 scripts."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import runpy
|
|
import sys
|
|
import tarfile
|
|
from typing import Sequence
|
|
|
|
|
|
def main(argv: Sequence[str] | None = None) -> None:
|
|
arguments = list(sys.argv[1:] if argv is None else argv)
|
|
if not arguments:
|
|
raise SystemExit("usage: proton_compat.py /path/to/proton [arguments...]")
|
|
proton = Path(arguments[0]).expanduser().resolve(strict=True)
|
|
proton_directory = str(proton.parent)
|
|
if proton_directory not in sys.path:
|
|
sys.path.insert(0, proton_directory)
|
|
if hasattr(tarfile, "fully_trusted_filter"):
|
|
setattr(
|
|
tarfile.TarFile,
|
|
"extraction_filter",
|
|
staticmethod(tarfile.fully_trusted_filter),
|
|
)
|
|
sys.argv = [str(proton), *arguments[1:]]
|
|
runpy.run_path(str(proton), run_name="__main__")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|