Extract get_proton_path_for_version

This commit is contained in:
Mathieu Comandon 2024-02-27 16:17:23 -08:00
parent 16df7887a4
commit 8b7190a384
2 changed files with 10 additions and 5 deletions

View file

@ -56,3 +56,11 @@ def list_proton_versions() -> List[str]:
if os.path.isfile(path):
versions.append(version)
return versions
def get_proton_path_for_version(version):
for proton_path in get_proton_paths():
if os.path.isfile(os.path.join(proton_path, version, "dist/bin/wine")):
return os.path.join(proton_path, version, "dist/bin/wine")
if os.path.isfile(os.path.join(proton_path, version, "files/bin/wine")):
return os.path.join(proton_path, version, "files/bin/wine")

View file

@ -138,11 +138,7 @@ def get_wine_path_for_version(version: str, config: dict = None) -> str:
if version in WINE_PATHS:
return system.find_executable(WINE_PATHS[version])
if "Proton" in version:
for proton_path in proton.get_proton_paths():
if os.path.isfile(os.path.join(proton_path, version, "dist/bin/wine")):
return os.path.join(proton_path, version, "dist/bin/wine")
if os.path.isfile(os.path.join(proton_path, version, "files/bin/wine")):
return os.path.join(proton_path, version, "files/bin/wine")
return proton.get_proton_path_for_version(version)
if version == "custom":
if config is None:
raise RuntimeError("Custom wine paths are only supported when a configuration is available.")
@ -158,6 +154,7 @@ def parse_wine_version(version: str) -> Tuple[List[int], str, str]:
Wine versions for correct parsing."""
version = version.replace("Proton7-", "Proton-7.")
version = version.replace("Proton8-", "Proton-8.")
version = version.replace("Proton9-", "Proton-9.")
return parse_version(version)