Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Windows: install-all follows multi-step fixes, the SDK installs its own git, and the venv packages ride in the zip

LNPANDY6d09bec8a733
diff --git a/.github/workflows/build-qt.yml b/.github/workflows/build-qt.yml
index 934bb2cb..7ef50981 100644
--- a/.github/workflows/build-qt.yml
+++ b/.github/workflows/build-qt.yml
@@ -38,6 +38,13 @@ jobs:
- name: Generate the localisation table
run: python frontend-qt/gen_localization.py
+ # The build packages ride in the zip: the venv step then installs from disk (--no-index),
+ # so a fresh machine needs no PyPI round-trip for lz4/capstone/fonttools/nsz. The runner's
+ # Python is the version these wheels target (3.12), matching the interpreter the app
+ # installs for its venv.
+ - name: Download the venv wheels
+ run: python -m pip download lz4 capstone fonttools backports.zstd nsz -d frontend-qt/wheels
+
- name: Build
working-directory: frontend-qt
shell: bash
@@ -123,6 +130,7 @@ jobs:
shell: bash
run: |
cd frontend-qt/dist
+ cp -r ../wheels "NS Port Builder/wheels"
powershell -Command "Compress-Archive -Path 'NS Port Builder' -DestinationPath '../NS-Port-Builder-qt-windows-x64.zip'"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.py
index 0c36cda9..e8c1cba6 100644
--- a/frontend-qt/nspb_qt/model.py
+++ b/frontend-qt/nspb_qt/model.py
@@ -307,7 +307,10 @@ class Model(QObject):
# exists).
for d in deps:
if not d.ok and d.detail:
- self.log(self.t('dep.row.log', d.title_key.replace('dep.', 'dep.').replace('.hint', ''),
+ # three placeholders, three args: a mismatch makes t() fall back to the raw
+ # "dependency %@: [%@] %@" line (the report's log had it six times)
+ name = d.title_key.replace('dep.', '').replace('.hint', '')
+ self.log(self.t('dep.row.log', name, d.state.value,
d.detail.replace('\n', ' | ')) + '\n')
if not pu.IS_WIN:
# On Windows `_windows_deps` already set python_path (the interpreter the app
@@ -754,6 +757,14 @@ class Model(QObject):
elif what == 'ios_sdk':
self.log(self.t('dep.iossdk.downloading') + '\n')
from .win import sdk_fetch as sf
+ # clone_sdk runs git, which a fresh machine has none of: the app installs
+ # PortableGit itself (per-user, no installer) instead of sending the player
+ # to git-scm.com — the report's SDK row failed three times on exactly that.
+ if not (wtc.git_exe() or shutil.which('git')):
+ self.log(self.t('dep.git.downloading') + '\n')
+ from .win import fetch as wf
+ git = wf.install_git(log=lambda s: self.log(str(s) + '\n'))
+ self.log(self.t('dep.git.done', str(git)) + '\n')
path = sf.clone_sdk(log=lambda s: self.log(str(s) + '\n'))
self.log(self.t('dep.iossdk.done', str(path)) + '\n')
ok = True
@@ -895,6 +906,26 @@ class Model(QObject):
return report
+ @staticmethod
+ def bundled_wheels() -> Path | None:
+ """The wheel folder shipped in the Windows zip (`wheels/` beside the exe).
+
+ The build packages (lz4, capstone, fonttools, nsz, backports.zstd) are downloaded by the
+ release workflow at packaging time, so the venv step installs from disk with no network
+ and no PyPI — the same "the app carries it" promise the Mac's bundled CPython makes.
+ Source runs have no such folder and fall back to PyPI.
+ """
+ base = getattr(sys, '_MEIPASS', None) or Path(sys.executable).parent
+ w = Path(base) / 'wheels'
+ return w if w.is_dir() and any(w.glob('*.whl')) else None
+
+ @staticmethod
+ def _pip_args(pkgs: list[str], wheels: Path | None) -> list[str]:
+ """pip's arguments: offline from the bundled wheels when they cover the packages."""
+ if wheels:
+ return ['install', '--no-index', '--find-links', str(wheels)] + pkgs
+ return ['install'] + pkgs
+
def _make_venv(self, base: str) -> bool:
"""Create or reuse the app's venv and install the build packages into it."""
vpy = pu.venv_python()
@@ -935,9 +966,12 @@ class Model(QObject):
pkgs = ['lz4', 'capstone', 'fonttools', 'nsz']
if ver < (3, 14):
pkgs.insert(3, 'backports.zstd')
- self.log(f'$ {vpy} -m pip install {" ".join(pkgs)}\n')
+ wheels = self.bundled_wheels()
+ args = self._pip_args(pkgs, wheels)
+ self.log(f'$ {vpy} -m pip {" ".join(args)}'
+ + ('' if wheels else ' (from PyPI)') + '\n')
try:
- p = subprocess.Popen([vpy, '-m', 'pip', 'install'] + pkgs, stdout=subprocess.PIPE,
+ p = subprocess.Popen([vpy, '-m', 'pip'] + args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, text=True, errors='replace',
env=pu.child_env(), **pu.no_window_kwargs())
assert p.stdout is not None
@@ -975,10 +1009,18 @@ class Model(QObject):
def run_all() -> None:
try:
- attempted: set[str] = set()
+ # attempted is keyed by (id, fix): an id may legitimately come back in a later
+ # pass with a DIFFERENT fix — installing the Python interpreter turns its row
+ # into "pip install the packages", which is exactly the step install-all must
+ # then run (the report: only the interpreter was installed, the packages step
+ # needed a second click on the row).
+ attempted: dict[str, tuple] = {}
while True:
- rows = [d for d in self.deps if not d.ok and d.install
- and d.id not in attempted]
+ def pending(d) -> bool:
+ if d.ok or not d.install:
+ return False
+ return attempted.get(d.id) != tuple(d.install)
+ rows = [d for d in self.deps if pending(d)]
if not rows:
break
progressed = False
@@ -986,7 +1028,9 @@ class Model(QObject):
live = next((r for r in self.deps if r.id == d.id), None)
if live is None or live.ok or not live.install or live.installing:
continue
- attempted.add(live.id)
+ if attempted.get(live.id) == tuple(live.install):
+ continue
+ attempted[live.id] = tuple(live.install)
self.log(f'--- {self.t(live.title_key)} ---\n')
self.install_dep(live)
progressed = True
diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.py
index 0d297f82..5f09bc4b 100644
--- a/frontend-qt/tests/test_win.py
+++ b/frontend-qt/tests/test_win.py
@@ -1706,6 +1706,27 @@ class LinkProbeStrategyTest(unittest.TestCase):
self.assertIn('dep.fix.nonascii', hinted)
+class VenvWheelsTest(unittest.TestCase):
+ """The build packages ride in the zip: the venv installs offline from wheels/ beside the
+ exe when it is there, and from PyPI exactly as before when it is not (source runs)."""
+
+ def test_offline_args_when_wheels_are_bundled(self) -> None:
+ from nspb_qt import model as M
+ args = M.Model._pip_args(['lz4', 'nsz'], Path('C:/app/wheels'))
+ self.assertEqual(args, ['install', '--no-index', '--find-links', 'C:/app/wheels', 'lz4', 'nsz'])
+
+ def test_pypi_args_when_not_bundled(self) -> None:
+ from nspb_qt import model as M
+ self.assertEqual(M.Model._pip_args(['lz4'], None), ['install', 'lz4'])
+
+ def test_the_log_row_string_takes_three_args(self) -> None:
+ from nspb_qt.i18n import Lang
+ from nspb_qt.localization import t
+ out = t('dep.row.log', Lang.EN, 'python', 'missing', 'C:/x | found')
+ self.assertEqual(out, 'dependency python: [missing] C:/x | found', 'the report log showed raw %@ placeholders')
+ self.assertTrue(t('dep.row.log', Lang.ZH, 'python', 'missing', 'd'), 'Chinese side is filled too')
+
+
class MetalPickFlowShapeTest(unittest.TestCase):
"""The model wiring (source-shape, since model.py needs PySide6): the metal row asks for a
file, takes a zip to install_metal_zip, a folder to _save_metal_folder."""
@@ -1783,7 +1804,7 @@ class InstallFailureHintTest(unittest.TestCase):
# pure function, so its source is extracted and run standalone when Qt is absent.
try:
from nspb_qt import model as M
- classify = M.BuildModel._classify_install_failure
+ classify = M.Model._classify_install_failure
except ImportError:
import ast
src = (HERE.parent / 'nspb_qt' / 'model.py').read_text()