mirror of
https://github.com/tcsenpai/UWINE.git
synced 2025-06-06 11:35:20 +00:00
Remove requirement for setting WINEPREFIX
- When $WINEPREFIX is not set, create a prefix directory in behalf of the user with the name being the ulwgl id. Currently, we create the directories as ~/Games/ULWGL/<ULWGL_ID>. In effect, the only required environment variable will be $GAMEID.
This commit is contained in:
parent
33bd82851a
commit
4baebf2e17
22
ulwgl_run.py
22
ulwgl_run.py
@ -103,19 +103,25 @@ def check_env(
|
|||||||
|
|
||||||
return toml
|
return toml
|
||||||
|
|
||||||
if "WINEPREFIX" not in os.environ:
|
|
||||||
err: str = "Environment variable not set or not a directory: WINEPREFIX"
|
|
||||||
raise ValueError(err)
|
|
||||||
|
|
||||||
if not Path(os.environ["WINEPREFIX"]).expanduser().is_dir():
|
|
||||||
Path(os.environ["WINEPREFIX"]).mkdir(parents=True)
|
|
||||||
env["WINEPREFIX"] = os.environ["WINEPREFIX"]
|
|
||||||
|
|
||||||
if "GAMEID" not in os.environ:
|
if "GAMEID" not in os.environ:
|
||||||
err: str = "Environment variable not set: GAMEID"
|
err: str = "Environment variable not set: GAMEID"
|
||||||
raise ValueError(err)
|
raise ValueError(err)
|
||||||
env["GAMEID"] = os.environ["GAMEID"]
|
env["GAMEID"] = os.environ["GAMEID"]
|
||||||
|
|
||||||
|
if (
|
||||||
|
"WINEPREFIX" not in os.environ
|
||||||
|
or not Path(os.environ["WINEPREFIX"]).expanduser().is_dir()
|
||||||
|
):
|
||||||
|
# Automatically create a prefix for the user if WINEPREFIX is not set
|
||||||
|
# The GAMEID will be the name of the dir
|
||||||
|
pfx: Path = Path.home().joinpath("Games/ULWGL/" + env["GAMEID"])
|
||||||
|
|
||||||
|
pfx.mkdir(parents=True, exist_ok=True)
|
||||||
|
os.environ["WINEPREFIX"] = pfx.as_posix()
|
||||||
|
env["WINEPREFIX"] = os.environ["WINEPREFIX"]
|
||||||
|
else:
|
||||||
|
env["WINEPREFIX"] = os.environ["WINEPREFIX"]
|
||||||
|
|
||||||
if "PROTONPATH" not in os.environ:
|
if "PROTONPATH" not in os.environ:
|
||||||
os.environ["PROTONPATH"] = ""
|
os.environ["PROTONPATH"] = ""
|
||||||
get_ulwgl_proton(env)
|
get_ulwgl_proton(env)
|
||||||
|
@ -1553,8 +1553,11 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
ulwgl_run.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
|
|
||||||
def test_env_vars_none(self):
|
def test_env_vars_none(self):
|
||||||
"""Tests check_env when setting no env vars."""
|
"""Tests check_env when setting no env vars.
|
||||||
with self.assertRaisesRegex(ValueError, "WINEPREFIX"):
|
|
||||||
|
GAMEID should be the only strictly required env var
|
||||||
|
"""
|
||||||
|
with self.assertRaisesRegex(ValueError, "GAMEID"):
|
||||||
ulwgl_run.check_env(self.env)
|
ulwgl_run.check_env(self.env)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user