Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support compatibility tools other than Proton out-of-the-box. #293

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ umu-launcher-install: umu-launcher-dist-install umu-launcher-bin-install
$(OBJDIR)/.build-umu-vendored: | $(OBJDIR)
$(info :: Building vendored dependencies )
python3 -m pip install urllib3 -t $(OBJDIR)
python3 -m pip install vdf -t $(OBJDIR)

.PHONY: umu-vendored
umu-vendored: $(OBJDIR)/.build-umu-vendored
Expand All @@ -110,6 +111,7 @@ umu-vendored-install: umu-vendored
$(info :: Installing subprojects )
install -d $(DESTDIR)$(PYTHONDIR)/umu/_vendor
cp -r $(OBJDIR)/urllib3 $(DESTDIR)$(PYTHONDIR)/umu/_vendor
cp -r $(OBJDIR)/vdf $(DESTDIR)$(PYTHONDIR)/umu/_vendor

$(OBJDIR):
@mkdir -p $(@)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ classifiers = [
urls = { repository = "https://github.com/Open-Wine-Components/umu-launcher" }
# Note: urllib3 is a vendored dependency. When using our Makefile, it will be
# installed automatically.
dependencies = ["python-xlib>=0.33", "filelock>=3.9.0", "urllib3>=2.0.0,<3.0.0"]
dependencies = ["python-xlib>=0.33", "filelock>=3.9.0", "urllib3>=2.0.0,<3.0.0", "vdf>=3.4"]

[project.optional-dependencies]
# Recommended
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-xlib>=0.33
filelock>=3.15.4
urllib3>=2.0.0,<3.0.0
vdf>=3.4
7 changes: 7 additions & 0 deletions umu/umu_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class GamescopeAtom(Enum):
"getnativepath",
}

RUNTIME_VERSIONS = {
# "1070560": ("scout", "steamrt1"),
"1391110": ("soldier", "steamrt2"),
"1628350": ("sniper", "steamrt3"),
# "": ("medic", "steamrt4"),
}

XDG_CACHE_HOME: Path = (
Path(os.environ["XDG_CACHE_HOME"])
if os.environ.get("XDG_CACHE_HOME")
Expand Down
78 changes: 39 additions & 39 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
from umu.umu_proton import get_umu_proton
from umu.umu_runtime import setup_umu
from umu.umu_util import (
CompatibilityTool,
SteamRuntime,
get_libc,
get_library_paths,
has_umu_setup,
Expand Down Expand Up @@ -134,7 +136,7 @@ def check_env(
env["WINEPREFIX"] = os.environ.get("WINEPREFIX", "")

# Skip Proton if running a native Linux executable
if os.environ.get("UMU_NO_PROTON") == "1":
if os.environ.get("UMU_NO_TOOL") == "1":
return env

# Proton Version
Expand Down Expand Up @@ -266,7 +268,7 @@ def set_env(
# Runtime
env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or ""
env["UMU_RUNTIME_UPDATE"] = os.environ.get("UMU_RUNTIME_UPDATE") or ""
env["UMU_NO_PROTON"] = os.environ.get("UMU_NO_PROTON") or ""
env["UMU_NO_TOOL"] = os.environ.get("UMU_NO_TOOL") or ""

# Proton logging (to stdout)
# Check for PROTON_LOG because it redirects output to log file
Expand Down Expand Up @@ -312,16 +314,13 @@ def enable_steam_game_drive(env: dict[str, str]) -> dict[str, str]:
def build_command(
env: dict[str, str],
local: Path,
opts: list[str] = [],
opts: list[str] | None = None,
) -> tuple[Path | str, ...]:
"""Build the command to be executed."""
shim: Path = local.joinpath("umu-shim")
proton: Path = Path(env["PROTONPATH"], "proton")
entry_point: Path = local.joinpath("umu")

if env.get("UMU_NO_PROTON") != "1" and not proton.is_file():
err: str = "The following file was not found in PROTONPATH: proton"
raise FileNotFoundError(err)
if opts is None:
opts = []

# Exit if the entry point is missing
# The _v2-entry-point script and container framework tools are included in
Expand All @@ -333,48 +332,49 @@ def build_command(
)
raise FileNotFoundError(err)

# Winetricks
if env.get("EXE", "").endswith("winetricks") and opts:
# The position of arguments matter for winetricks
# Usage: ./winetricks [options] [command|verb|path-to-verb] ...
return (
entry_point,
"--verb",
env["PROTON_VERB"],
"--",
proton,
env["PROTON_VERB"],
env["EXE"],
"-q",
*opts,
)

runtime = SteamRuntime(local.as_posix())
# Will run the game within the Steam Runtime w/o Proton
# Ideally, for reliability, executables should be compiled within
# the Steam Runtime
if env.get("UMU_NO_PROTON") == "1":
if env.get("UMU_NO_TOOL") == "1":
log.debug(
"Compatibility tool disabled. Executing linux-native executable %s", env["EXE"]
)
return (
entry_point,
"--verb",
env["PROTON_VERB"],
"--",
*runtime.command(env["PROTON_VERB"]),
env["EXE"],
*opts,
)

# Setup compatibility tool
# If the user explicitly requested to run without the runtime,
# force runtime to None
compat_tool = CompatibilityTool(
env["PROTONPATH"],
shim,
None if env["UMU_NO_RUNTIME"] == "1" else runtime
)
log.info("Using compatibility tool %s", compat_tool.display_name)
# Will run the game outside the Steam Runtime w/ Proton
if env.get("UMU_NO_RUNTIME") == "1":
if not compat_tool.runtime_enabled:
log.warning("Runtime Platform disabled")
return proton, env["PROTON_VERB"], env["EXE"], *opts

# Winetricks
if env.get("EXE", "").endswith("winetricks") and opts:
if compat_tool.layer != "proton":
err: str = "Winetricks is available only on Proton and Proton-derived tools"
raise ValueError(err)
# The position of arguments matter for winetricks
# Usage: ./winetricks [options] [command|verb|path-to-verb] ...
return (
*compat_tool.command(env["PROTON_VERB"]),
env["EXE"],
"-q",
*opts,
)

return (
entry_point,
"--verb",
env["PROTON_VERB"],
"--",
shim,
proton,
env["PROTON_VERB"],
*compat_tool.command(env["PROTON_VERB"]),
env["EXE"],
*opts,
)
Expand Down Expand Up @@ -771,7 +771,7 @@ def umu_run(args: Namespace | tuple[str, list[str]]) -> int:
"UMU_ZENITY": "",
"UMU_NO_RUNTIME": "",
"UMU_RUNTIME_UPDATE": "",
"UMU_NO_PROTON": "",
"UMU_NO_TOOL": "",
}
opts: list[str] = []
prereq: bool = False
Expand Down
Loading
Loading