feat: find Steam libraries from the client folder

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 14:53:53 +01:00
1 parent 92e374328f
commit 26be1152ea
6 files changed
+53 -23

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
# the site's build rewrites this line there (scripts/sitebootstrap.py).
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
$defaultInstallSha256 = "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78"
$defaultInstallSha256 = "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d"
$maximumInstallerBytes = 2MB
$installerExit = 0
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
+15 -12
View File
@@ -1324,13 +1324,22 @@ def _steam_libraries() -> list[Path]:
Steam lists the others in steamapps/libraryfolders.vdf, each as a
"path" line. A RetroArch installed on D:/SteamLibrary was not found
when only Program Files was searched.
when only Program Files was searched. The client's own folder is the
SteamPath value it writes under HKCU\\Software\\Valve\\Steam, read the
same way by Playnite (PlayniteExtensions 886468f6,
source/Libraries/SteamLibrary/Steam.cs:34-38): a client installed in
D:\\Steam hid every library.
"""
roots: list[Path] = []
steam_path = _read_registry("HKCU\\Software\\Valve\\Steam", "SteamPath")
candidates = [_host_path(steam_path.replace("/", "\\"))] if steam_path else []
for var in ("ProgramFiles(x86)", "ProgramFiles"):
base = os.environ.get(var, "")
if base and _is_dir(Path(base) / "Steam"):
roots.append(Path(base) / "Steam")
if base:
candidates.append(Path(base) / "Steam")
for candidate in candidates:
if candidate not in roots and _is_dir(candidate):
roots.append(candidate)
libraries = list(roots)
for root in roots:
vdf = root / "steamapps" / "libraryfolders.vdf"
@@ -2919,15 +2928,9 @@ def detect_platforms(os_type: str) -> list[tuple[str, Path]]:
if ra_dir:
found.append(("retroarch", ra_dir))
# RetroArch from Steam: a portable install under the default library
for var in ("ProgramFiles(x86)", "ProgramFiles"):
program_files = os.environ.get(var, "")
if not program_files:
continue
steam_cfg = (
Path(program_files) / "Steam" / "steamapps" / "common"
/ "RetroArch" / "retroarch.cfg"
)
# RetroArch from Steam: a portable install in a Steam library
for library in _steam_libraries():
steam_cfg = library / "steamapps" / "common" / "RetroArch" / "retroarch.cfg"
ra_dir = _parse_retroarch_system_dir(steam_cfg)
if ra_dir and not any(name == "retroarch" for name, _ in found):
found.append(("retroarch", ra_dir))
+1 -1
View File
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
# curl or wget stop on a cut transfer before the hash is read: the site's
# build rewrites this line there (scripts/sitebootstrap.py).
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
DEFAULT_INSTALL_SHA256="5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78"
DEFAULT_INSTALL_SHA256="ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d"
MAX_INSTALLER_BYTES=2097152
cleanup() {
+8 -8
View File
@@ -27,8 +27,8 @@
{
"dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py",
"size": 1117350,
"sha256": "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78",
"size": 1117672,
"sha256": "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d",
"executable": false
},
{
@@ -71,8 +71,8 @@
"muos": {
"archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1170977,
"sha256": "cfb61e90dafef4fceadd8750412fe91a98b5d8cbf9574c819c09bddb76486e78"
"size": 1171299,
"sha256": "3329f55c1b46d953dd8745c0ff508315db8185e0530c842beb6e944d7262ac5a"
},
"members": [
{
@@ -92,8 +92,8 @@
{
"name": "RetroBIOS/install.py",
"repo_path": "install.py",
"size": 1117350,
"sha256": "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78",
"size": 1117672,
"sha256": "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d",
"executable": false
},
{
@@ -166,8 +166,8 @@
{
"dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py",
"size": 1117350,
"sha256": "5bce9f0f81e4f1c7302ca78fa5242f26acc06523f8718378ee97042f2421ff78",
"size": 1117672,
"sha256": "ed2094adddcafccf57250f16c5e5bcf2ede1d741e0b0f94094ae9828c685431d",
"executable": false
},
{
+27
View File
@@ -4511,6 +4511,33 @@ class WindowsSeenFromWsl(unittest.TestCase):
self.assertEqual(os.environ["ProgramFiles"], "")
def test_a_steam_client_outside_program_files_is_found(self):
"""A Steam client in D:\\Steam hid every library: only Program Files
was searched, and Steam's RetroArch was not detected."""
empty = self.root / "c" / "Program Files (x86)"
empty.mkdir(parents=True)
common = self.root / "d" / "steam" / "steamapps" / "common" / "RetroArch"
common.mkdir(parents=True)
(common / "retroarch.exe").write_bytes(b"MZ")
(common / "retroarch.cfg").write_text('system_directory = "default"\n')
home = Path(_tempdir(self))
cleared = {name: "" for name in (*install._WINDOWS_VARIABLES, "SCOOP", "SCOOP_GLOBAL",
"ProgramData")}
asked: list = []
def registry(key, value):
asked.append((key, value))
return "d:/steam" if (key, value) == ("HKCU\\Software\\Valve\\Steam",
"SteamPath") else None
with unittest.mock.patch.dict(os.environ, {**cleared, "HOME": str(home),
"ProgramFiles(x86)": str(empty)}), \
unittest.mock.patch.object(Path, "home", return_value=home), \
unittest.mock.patch.object(install, "_read_registry", registry):
self.assertEqual(install._steam_libraries(), [self.root / "d" / "steam"])
found = install.detect_platforms("wsl")
self.assertIn(("retroarch", common / "system"), found)
def test_windows_not_answering_is_said_not_taken_for_nothing(self):
"""cmd.exe timing out on the first variable ended the import without
a word, and detection said no setup was installed."""
+1 -1
View File
@@ -1181,7 +1181,7 @@ usual folders of a setup that has one on each side: RetroArch's in this Linux
| `~/Library/Application Support/RetroArch/config/retroarch.cfg` | RetroArch (macOS) | `system_directory`. At default, `~/Documents/RetroArch/system` (portable, Steam build included: `Application Support/RetroArch/system`) |
| `retroarch.cfg` beside `retroarch.exe` (`C:\RetroArch-Win64`, `C:\RetroArch`, `Program Files\RetroArch`) | RetroArch (Windows) | `system_directory`. At default or without a config, `system` beside the exe |
| `%APPDATA%\RetroArch\retroarch.cfg` | RetroArch (Windows) | `system_directory`, read when the exe folder has no config |
| `%ProgramFiles(x86)%\Steam\steamapps\common\RetroArch\retroarch.cfg` | RetroArch (Steam) | `system_directory` |
| `steamapps\common\RetroArch\retroarch.cfg` in every Steam library: the client's folder (`SteamPath` under `HKCU\Software\Valve\Steam`, else `%ProgramFiles(x86)%\Steam`) and the libraries its `libraryfolders.vdf` lists | RetroArch (Steam) | `system_directory` |
| `%LOCALAPPDATA%\Packages\1e4cf179-f3c2-404f-b9f3-cb2070a5aad8_*\LocalState` | RetroArch (UWP/MSIX package) | `system_directory` of the `retroarch.cfg` there, `~` meaning that folder. By default `LocalState\system` |
| LaunchBox `Data\Emulators.xml` | RetroArch (portable) | the system directory that entry points at |
| LaunchBox `Data\Emulators.xml` naming `EmuHawk.exe` | BizHawk (portable) | `Firmware` beside `EmuHawk.exe` |