mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-18 20:15:56 +00:00
Start the rebuild window and its setup run with a Python that finds the installer
The rebuild command puts the release folder on sys.path itself: totk.exe starts it in the install folder, and only the Windows release Python's ._pth names that folder. In a repository the window and its setup run use the Python that runs the setup, since the tools' embeddable Python there has neither tkinter nor the repository on its path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4310407226
commit
3668271182
4 files changed
+21
-9
No files matched your search
+3
-2
@@ -83,8 +83,9 @@ Ninja recompiles only those: a new or edited code cheat costs the lift (under a
|
||||
and a few dozen chunks, not a full compile, and the shaders stay prepared.
|
||||
|
||||
`build-cache/rebuild.txt` holds the command that opens the setup window in its rebuild mode on the install folder
|
||||
(`python -m installer.gui --rebuild <install folder>`), one argument per line. When an enabled mod has code cheats or
|
||||
ExeFS patch files the build lacks, `totk.exe` runs it at start and exits (`runtime/cheats.c` `rebuild_if_needed`); the
|
||||
(`installer/gui.py --rebuild <install folder>`, started through `python -c` so the release folder is on `sys.path`
|
||||
whatever the working folder), one argument per line. When an enabled mod has code cheats or ExeFS patch files the build
|
||||
lacks, `totk.exe` runs it at start and exits (`runtime/cheats.c` `rebuild_if_needed`); the
|
||||
window runs the setup on the folder at once and starts the game again when it succeeds. A failed or cancelled rebuild
|
||||
offers to start the game with the code it has; `build-cache/rebuild.skip` then keeps the same files from starting it
|
||||
again, until "Rebuild the game now" on the Cheats or Mods tab. `[mods] mods_rebuild = off` turns it off. The rebuild
|
||||
|
||||
+4
-1
@@ -325,7 +325,10 @@ class App:
|
||||
self.fit()
|
||||
return
|
||||
self.form_error.configure(text='')
|
||||
command = form.command(self.layout.python, root=self.layout.root if self.layout.dev else None,
|
||||
# in a repository the Python running this window: the tools' embeddable Python there has no ._pth entry for
|
||||
# the repository, so `-m installer` would not find the package
|
||||
python = Path(sys.executable) if self.layout.dev else self.layout.python
|
||||
command = form.command(python, root=self.layout.root if self.layout.dev else None,
|
||||
temp=self.run_args.get('temp'), verify_hashes=self.run_args.get('verify', False))
|
||||
self.begin(command, self.layout.root)
|
||||
|
||||
|
||||
+11
-3
@@ -1031,14 +1031,22 @@ class Cleanup(Step):
|
||||
return {}
|
||||
|
||||
|
||||
# Puts the release folder (the argument after -c) on sys.path and runs installer.gui with the rest. `-m installer.gui`
|
||||
# finds the package only through the release Python's ._pth: the Linux release's Python and the dev-mode embeddable one
|
||||
# lack that entry, and totk.exe starts the command in the install folder.
|
||||
REBUILD_BOOT = ('import runpy, sys; sys.path.insert(0, sys.argv.pop(1)); '
|
||||
"runpy.run_module('installer.gui', run_name='__main__', alter_sys=True)")
|
||||
|
||||
|
||||
def rebuild_command(ctx):
|
||||
"""The command that starts the setup window in its rebuild mode on this install folder (installer/gui.py
|
||||
--rebuild): pythonw beside the setup's Python on Windows, so no console opens."""
|
||||
--rebuild): pythonw beside the setup's Python on Windows, so no console opens. In a repository that is the Python
|
||||
running this setup: the tools' embeddable Python there has no tkinter."""
|
||||
layout = ctx.layout
|
||||
python = layout.python
|
||||
python = Path(sys.executable) if layout.dev else layout.python
|
||||
if os.name == 'nt' and python.with_name('pythonw.exe').is_file():
|
||||
python = python.with_name('pythonw.exe')
|
||||
return [str(python), '-m', 'installer.gui', '--root', str(layout.root), '--rebuild', str(ctx.dest)]
|
||||
return [str(python), '-c', REBUILD_BOOT, str(layout.root), '--root', str(layout.root), '--rebuild', str(ctx.dest)]
|
||||
|
||||
|
||||
def write_rebuild_command(ctx):
|
||||
|
||||
@@ -326,7 +326,7 @@ class CleanupTest(unittest.TestCase):
|
||||
self.expected = {'romfs': {'size': len(image), 'sha256': digest}}
|
||||
self.ctx = SimpleNamespace(reporter=Reporter(out=io.StringIO(), log_path=base / 'x.log'), dest=self.dest,
|
||||
temp=temp, lang='en-US', state={},
|
||||
layout=SimpleNamespace(ini_example=ROOT / 'totk.ini.example',
|
||||
layout=SimpleNamespace(ini_example=ROOT / 'totk.ini.example', dev=False,
|
||||
python=base / 'python' / 'python.exe', root=base / 'release'))
|
||||
self.saved = steps.expected_update
|
||||
steps.expected_update = lambda ctx: self.expected
|
||||
@@ -353,8 +353,8 @@ class CleanupTest(unittest.TestCase):
|
||||
self.assertTrue((self.ctx.temp / 'gen').is_dir() and (self.ctx.temp / 'build').is_dir())
|
||||
self.assertFalse((self.ctx.temp / 'check').exists())
|
||||
lines = (self.dest / 'build-cache' / 'rebuild.txt').read_text(encoding='utf-8').splitlines()
|
||||
self.assertEqual(lines[1:], ['-m', 'installer.gui', '--root', str(self.ctx.layout.root), '--rebuild',
|
||||
str(self.dest)])
|
||||
self.assertEqual(lines[1:], ['-c', steps.REBUILD_BOOT, str(self.ctx.layout.root), '--root',
|
||||
str(self.ctx.layout.root), '--rebuild', str(self.dest)])
|
||||
|
||||
def test_emptied_romfs_fails(self):
|
||||
for p in (self.dest / 'romfs').iterdir():
|
||||
|
||||
Reference in new issue
Block a user