Skip to content

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

Windows front end: what the fourth handheld report found

LNPANDY531e8b448cb1
diff --git a/frontend-qt/nspb_qt/localization.py b/frontend-qt/nspb_qt/localization.py
index bcdeaddc..6e4f7d08 100644
--- a/frontend-qt/nspb_qt/localization.py
+++ b/frontend-qt/nspb_qt/localization.py
@@ -146,7 +146,10 @@ TABLE: dict[str, tuple[str, str]] = {
'dep.python.missing': ('%@ 缺包', '%@ is missing packages'),
'dep.install.begin': ('开始安装 %@…', 'Installing %@…'),
'dep.install.fail': ('安装失败:%@(详情见日志)', 'Install failed: %@ (see the log)'),
- 'dep.python.old': ('Python %@ 太旧(需要 %@ 或更新);系统的 /usr/bin/python3 没有这些包', 'Python %@ is too old (need %@ or newer); the system /usr/bin/python3 has none of these packages'),
+ 'dep.python.old': ('Python %@ 太旧(需要 3.9 或更新);这个解释器没有构建需要的包', 'Python %@ is too old (need 3.9 or newer); it lacks the packages the build needs'),
+ 'dep.python.none': ('没找到可用的 Python(%@ 不行)——点右侧「安装」,App 会下载 3.12 并静默装到自己的目录', 'No usable Python found (%@ will not run) — press Install and the app fetches 3.12 into its own folder'),
+ 'dep.python.downloading': ('正在下载并安装 Python 3.12…(约 26 MB,装到 App 自己的目录)', "Downloading and installing Python 3.12… (about 26 MB, into the app's own folder)"),
+ 'dep.python.done': ('Python 已安装:%@', 'Python installed: %@'),
'prog.title': ('构建进度', 'Build progress'),
'prog.empty': ('开始构建后,这里显示脚本自己的每个阶段', "The script's own stages appear here once the build starts"),
'prog.archive': ('RomFS 归档分片(200 MiB/片)', 'RomFS archive shards (200 MiB each)'),
diff --git a/frontend-qt/nspb_qt/model.py b/frontend-qt/nspb_qt/model.py
index a6346f34..528333ab 100644
--- a/frontend-qt/nspb_qt/model.py
+++ b/frontend-qt/nspb_qt/model.py
@@ -189,21 +189,36 @@ class Model(QObject):
self.deps_checked = True
self.depsChanged.emit()
+ def _python_row(self, py: str, py_ok: bool, py_ver: str) -> Dep:
+ """The interpreter row: fine, missing packages, missing interpreter, or too old.
+
+ "Too old" is wrong when the machine has no interpreter at all — the report's handheld
+ fails `python3 --version`, and the old two-placeholder string rendered with one argument
+ put a literal %@ on screen. A missing interpreter is its own state, and on Windows its
+ fix is the in-app installer.
+ """
+ if py_ok:
+ return Dep('python', 'dep.python', 'dep.python.hint', DepState.OK, py)
+ if py_ver and pu._ver_tuple(py_ver) >= (3, 9):
+ return Dep('python', 'dep.python', 'dep.python.hint', DepState.MISSING,
+ f'dep.python.missing:{py} ({py_ver})',
+ install=[py, '-m', 'pip', 'install', 'lz4', 'capstone', 'fonttools',
+ 'backports.zstd', 'nsz'])
+ if pu.IS_WIN:
+ return Dep('python', 'dep.python', 'dep.python.hint', DepState.MISSING,
+ f'dep.python.none:{py or "python3"}',
+ install=['__win__:python'])
+ return Dep('python', 'dep.python', 'dep.python.hint', DepState.OLD,
+ f'dep.python.old:{py_ver or "?"}')
+
def _check_deps(self) -> None:
deps: list[Dep] = []
- # Python + packages
+ # Python + packages. The Windows refinement (the interpreter the app installed for
+ # itself) happens in `_windows_deps`, which is the only place allowed to load the
+ # Windows-only modules.
py, py_ok, py_ver = pu.find_python()
- if py_ok:
- deps.append(Dep('python', 'dep.python', 'dep.python.hint', DepState.OK, py))
- elif py_ver and pu._ver_tuple(py_ver) >= (3, 9):
- deps.append(Dep('python', 'dep.python', 'dep.python.hint', DepState.MISSING,
- f'dep.python.missing:{py} ({py_ver})',
- install=[py, '-m', 'pip', 'install', 'lz4', 'capstone', 'fonttools',
- 'backports.zstd', 'nsz']))
- else:
- deps.append(Dep('python', 'dep.python', 'dep.python.hint', DepState.OLD,
- f'dep.python.old:{py_ver or "?"}:3.9'))
+ deps.append(self._python_row(py, py_ok, py_ver))
# .NET. On Windows the row comes from `_windows_deps()` instead: there the check has to be
# "SDK 10 or newer is installed" (nx_extract targets net10.0) and the fix is an in-app
@@ -219,7 +234,7 @@ class Model(QObject):
# Xcode (macOS) or the cross toolchain (Windows)
if pu.IS_WIN:
- deps.extend(self._windows_deps())
+ deps.extend(self._windows_deps(deps))
else:
xc = pu.xcode_ok()
sdk = xc and pu.ios_sdk_ok()
@@ -278,7 +293,7 @@ class Model(QObject):
# ---- Windows toolchain rows
- def _windows_deps(self) -> list[Dep]:
+ def _windows_deps(self, deps: list[Dep]) -> list[Dep]:
"""The Windows cross toolchain, in the order it matters.
The checks come from `nspb_qt.win.toolchain`, which runs the real compilers for the
@@ -293,6 +308,17 @@ class Model(QObject):
out: list[Dep] = []
probes = wtc.check_all(deep=True)
+
+ # Re-do the Python row now that the toolchain can speak: the interpreter this app
+ # installed for itself is not on PATH and not in Program Files, so the row built before
+ # this point reported "no usable Python" on the very machine that had just installed one
+ # (and after such an install, this is what makes the row go green).
+ own = wtc.python_dir()
+ if own:
+ py2, ok2, ver2 = pu.find_python([str(own / 'python.exe')])
+ if py2 != (self.deps[0].detail if self.deps else None):
+ deps[0] = self._python_row(py2, ok2, ver2)
+ self.python_path, self.python_ok, self.python_ver = py2, ok2, ver2
by_id = {p.id: p for p in probes}
def state(p) -> DepState:
@@ -634,6 +660,13 @@ class Model(QObject):
unpack_progress=progress_logger(self.t('dep.phase.unpack')))
self.log(self.t('dep.dotnet.done', str(path)) + '\n')
ok = True
+ elif what == 'python':
+ self.log(self.t('dep.python.downloading') + '\n')
+ path = wf.install_python(
+ log=lambda s: self.log(str(s) + '\n'),
+ progress=progress_logger(self.t('dep.phase.download')))
+ self.log(self.t('dep.python.done', str(path)) + '\n')
+ ok = True
elif what == 'llvm':
self.log(self.t('dep.llvm.downloading') + '\n')
path = wf.install_llvm(
@@ -718,19 +751,27 @@ class Model(QObject):
handheld: LLVM and SDK lines mixed). Order also matters for correctness — the SDK is
fetched with git, which the git row may be installing.
- The list is snapshotted once, and the wait is on that same `Dep` object: `_install_win`
- ends with `check_deps()`, which replaces `self.deps` with fresh objects, so re-reading
- `self.deps` mid-run would wait on a `Dep` nobody is installing and every later row would
- look finished instantly.
+ The plan (which ids, in which order) is snapshotted once, but **the row object is
+ re-resolved by id at every step**. `_install_win` ends with `check_deps()`, which
+ replaces every `Dep` in `self.deps`, and the panel renders those new objects: installing
+ on a snapshot is invisible to the UI, so a row showed Install (enabled!) while its
+ download ran, and nothing ever looked busy — the report's "the SDK is a cross but its
+ Install is grey" is this state machine crossed with itself. Waiting is also on the live
+ object, for the same reason. A Python install changes the very row it runs from (once
+ the interpreter is there the row's fix becomes "pip install the packages"), which only
+ works when the row is re-read.
"""
- pending = [d for d in self.deps if not d.ok and d.install]
+ pending = [d.id for d in self.deps if not d.ok and d.install]
if not pending or getattr(self, '_install_all_running', False):
return
self._install_all_running = True
def run_all() -> None:
try:
- for d in pending:
+ for dep_id in pending:
+ d = next((r for r in self.deps if r.id == dep_id), None)
+ if d is None or d.ok or not d.install:
+ continue # gone, or an earlier step fixed it
self.log(f'--- {self.t(d.title_key)} ---\n')
self.install_dep(d)
waited = 0.0
diff --git a/frontend-qt/nspb_qt/platform_util.py b/frontend-qt/nspb_qt/platform_util.py
index 392db02d..d311b5cc 100644
--- a/frontend-qt/nspb_qt/platform_util.py
+++ b/frontend-qt/nspb_qt/platform_util.py
@@ -28,12 +28,15 @@ def _which(name: str, extra: list[str] | None = None) -> str | None:
return None
-def find_python() -> tuple[str, bool, str]:
+def find_python(extra_candidates: list[str] | None = None) -> tuple[str, bool, str]:
"""The interpreter to build with: (path, has_packages, version_or_empty).
The build scripts need lz4, capstone, fontTools, zstd and (for compressed dumps) nsz. A
system interpreter rarely has them, so the venv the app manages is checked first, then
- every python on the machine.
+ every python on the machine. `extra_candidates` puts paths ahead of the system probes
+ without this module knowing about Windows specifics: the caller passes the interpreter the
+ app installed for itself (toolchain.python_dir), which a machine with no system Python is
+ exactly the one that has to be found again.
"""
probe = (
"import lz4, capstone, fontTools\n"
@@ -42,7 +45,7 @@ def find_python() -> tuple[str, bool, str]:
"except ImportError:\n"
" from backports import zstd\n"
)
- cands: list[str] = [venv_python()]
+ cands: list[str] = [venv_python()] + [c for c in (extra_candidates or []) if c]
if IS_WIN:
cands += [
os.path.expandvars(r'%LOCALAPPDATA%\Programs\Python\Python312\python.exe'),
diff --git a/frontend-qt/nspb_qt/win/fetch.py b/frontend-qt/nspb_qt/win/fetch.py
index 32d630c1..1b69a82b 100644
--- a/frontend-qt/nspb_qt/win/fetch.py
+++ b/frontend-qt/nspb_qt/win/fetch.py
@@ -209,12 +209,13 @@ def install_llvm(arch: str | None = None, dest: Path | None = None,
asset = tc.download_asset(arch)
root = Path(dest) if dest else tc.tools_dir()
target = root / f'llvm-mingw-{tc.LLVM_MINGW_VERSION}'
- if (target / 'bin' / 'clang.exe').is_file():
- log(f'LLVM-MinGW already installed: {target}')
- else:
- cache = root / 'downloads'
- zpath = download(asset['url'], cache / asset['name'], asset['sha256'], asset['size'],
- log=log, progress=progress)
+ cache = root / 'downloads'
+ zpath = cache / asset['name']
+
+ def unpack():
+ """Unpack the (cached) archive into `target`, replacing whatever is there."""
+ if not zpath.is_file():
+ raise DownloadError(f'{zpath.name} is not in the download cache: download it first')
log(f'unpacking {zpath.name} → {target} (about 1 GiB on disk)')
staging = root / f'.unpack-{tc.LLVM_MINGW_VERSION}'
shutil.rmtree(staging, ignore_errors=True)
@@ -257,7 +258,33 @@ def install_llvm(arch: str | None = None, dest: Path | None = None,
shutil.rmtree(target, ignore_errors=True)
target.parent.mkdir(parents=True, exist_ok=True)
staging.replace(target)
- log(f'LLVM-MinGW {tc.LLVM_MINGW_VERSION} installed: {target}')
+ log(f'LLVM-MinGW {tc.LLVM_MINGW_VERSION} unpacked: {target}')
+
+ def clang_runs() -> bool:
+ """Whether the installed clang.exe actually executes (not a half-written unpack)."""
+ return bool(tc.llvm_version(target / 'bin' / 'clang.exe'))
+
+ if (target / 'bin' / 'clang.exe').is_file():
+ if clang_runs():
+ log(f'LLVM-MinGW already installed: {target}')
+ else:
+ # File existence is not installation. An unpack killed mid-way (the app closed during
+ # the slow 1 GiB extraction — the report's "install never finishes") leaves a target
+ # folder whose clang.exe exists but cannot run, and from then on every check said
+ # "does not run (a partial or 32-bit install?)" while every install said "already
+ # installed". The archive is cached, so the repair is a re-unpack, not a re-download.
+ log(f'{target} holds an unusable clang.exe — the unpack did not finish; unpacking '
+ f'again from the cached archive')
+ unpack()
+ if not clang_runs():
+ raise DownloadError(
+ f'LLVM-MinGW was unpacked but {target / "bin" / "clang.exe"} still does not '
+ 'run. Delete that folder and install again; if it keeps failing, the archive '
+ 'or this machine\'s emulator is at fault — send the log.')
+ else:
+ zpath = download(asset['url'], zpath, asset['sha256'], asset['size'],
+ log=log, progress=progress)
+ unpack()
# make the Mach-O linker available in this brand-new folder
old = {k: os.environ.get(k) for k in ('NSPB_LLVM_DIR',)}
os.environ['NSPB_LLVM_DIR'] = str(target)
@@ -338,6 +365,49 @@ def install_dotnet(dest: Path | None = None,
return target
+def install_python(dest: Path | None = None,
+ log: Callable[[str], None] | None = None,
+ progress: Callable[[int, int], None] | None = None) -> Path:
+ r"""Install CPython per-user into the app's tools folder, silently, no administrator rights.
+
+ For a machine whose dependency row reads "Python too old" because there is no interpreter at
+ all (the handheld: `python3 --version` fails). The python.org installer supports exactly
+ this: `/quiet InstallAllUsers=0 TargetDir=…` installs without elevation into the folder we
+ name, which keeps it inside `%LOCALAPPDATA%\NS Port Builder\tools` — writable, and it
+ survives app updates like every other tool the app fetches.
+
+ `Include_pip=1` matters: the interpreter alone is not enough, the build needs lz4, capstone,
+ fonttools and nsz, and the front end installs those into a venv made from this interpreter.
+ The bootstrapper blocks until the install finishes, so the caller can probe the result.
+ """
+ log = log or (lambda s: None)
+ asset = tc.PYTHON_ASSET
+ root = Path(dest) if dest else tc.tools_dir()
+ target = root / f'python-{tc.PYTHON_VERSION}'
+ if tc._runs_quiet(target / 'python.exe'):
+ log(f'Python {tc.PYTHON_VERSION} already installed: {target}')
+ return target
+ cache = root / 'downloads'
+ exe = download(asset['url'], cache / asset['name'], asset['sha256'], asset['size'],
+ log=log, progress=progress)
+ log(f'installing Python {tc.PYTHON_VERSION} → {target} (per-user, no administrator rights)')
+ cmd = [str(exe), '/quiet', '/norestart', 'InstallAllUsers=0',
+ f'TargetDir={target}', 'Include_pip=1', 'Include_launcher=0',
+ 'AssociateFiles=0', 'Shortcuts=0', 'PrependPath=0', 'Include_doc=0']
+ r = subprocess.run(cmd, capture_output=True, text=True, errors='replace',
+ timeout=900, **tc.no_window())
+ if r.returncode != 0 or not tc._runs_quiet(target / 'python.exe'):
+ log(f'installer exit {r.returncode}: {(r.stdout or r.stderr or "")[:300]}')
+ raise DownloadError(
+ f'Python {tc.PYTHON_VERSION} did not install (exit {r.returncode}). '
+ f'Install it by hand from python.org, or point "python_dir" in toolchain.json at an '
+ f'existing interpreter.')
+ ver = subprocess.run([str(target / 'python.exe'), '--version'], capture_output=True,
+ text=True, timeout=60, **tc.no_window())
+ log(f'Python installed: {(ver.stdout or ver.stderr or "").strip()} at {target}')
+ return target
+
+
def metal_tools_hint() -> str:
return (f'Apple "Metal Developer Tools for Windows" {tc.METAL_TOOLS_VERSION}: '
f'{tc.METAL_TOOLS_URL}')
diff --git a/frontend-qt/nspb_qt/win/sdk_fetch.py b/frontend-qt/nspb_qt/win/sdk_fetch.py
index ac6cf72b..0fe073fc 100644
--- a/frontend-qt/nspb_qt/win/sdk_fetch.py
+++ b/frontend-qt/nspb_qt/win/sdk_fetch.py
@@ -112,7 +112,12 @@ def clone_sdk(version: str = tc.SDK_PINNED, dest: Path | None = None,
# GitHub, and a mainland connection that took 974 s for a 182 MB release asset is not going to
# enjoy a shallow clone either. The mirrors are git-protocol proxies, so the SHA of the
# checkout is unchanged — and the SDK is verified by its own layout afterwards.
- clone_args = ['clone', '--filter=blob:none', '--sparse', '--depth', '1']
+ # -c core.longpaths=true: the SDK trees carry paths past Windows' 260-character MAX_PATH
+ # (a swiftinterface inside System/Cryptexes/… tops it), and without this the sparse checkout
+ # dies with "Filename too long" — the report's third attempt at the SDK. The config is
+ # clone-scoped, so the user's own git is untouched.
+ clone_args = ['-c', 'core.longpaths=true', 'clone', '--filter=blob:none', '--sparse',
+ '--depth', '1']
last: Exception | None = None
for i, repo in enumerate(tc.mirror_urls(tc.SDK_REPO)):
if i:
@@ -132,10 +137,12 @@ def clone_sdk(version: str = tc.SDK_PINNED, dest: Path | None = None,
if last is not None:
rmtree(work)
raise last
- # narrow the working tree to the one SDK before checking anything out
+ # narrow the working tree to the one SDK before checking anything out (same long-paths
+ # config: -c applies to one command only, so this call carries it too)
try:
- subprocess.run([git, 'sparse-checkout', 'set', version], cwd=str(work),
- check=True, capture_output=True, text=True, **tc.no_window())
+ subprocess.run([git, '-c', 'core.longpaths=true', 'sparse-checkout', 'set', version],
+ cwd=str(work), check=True, capture_output=True, text=True,
+ encoding='utf-8', errors='replace', **tc.no_window())
except subprocess.CalledProcessError as e:
raise SdkError(f'git sparse-checkout failed: {(e.stderr or "").strip()[-400:]}') from e
src = work / version
diff --git a/frontend-qt/nspb_qt/win/toolchain.py b/frontend-qt/nspb_qt/win/toolchain.py
index 86706a1f..f1bc5b63 100644
--- a/frontend-qt/nspb_qt/win/toolchain.py
+++ b/frontend-qt/nspb_qt/win/toolchain.py
@@ -151,6 +151,19 @@ DOTNET_ASSET = {
'size': 300745255,
}
+#: Python for Windows, for machines with no usable interpreter at all (the report's handheld:
+#: `python3 --version` fails, so the dependency row could only say "too old" and pip-install into
+#: a python that is not there). The per-user installer: `/quiet InstallAllUsers=0 TargetDir=…`
+#: needs no administrator rights and lands in the app's own tools folder. SHA-256 taken from the
+#: downloaded artifact (python.org publishes it on the release page as well).
+PYTHON_VERSION = '3.12.10'
+PYTHON_ASSET = {
+ 'name': f'python-{PYTHON_VERSION}-amd64.exe',
+ 'url': f'https://www.python.org/ftp/python/{PYTHON_VERSION}/python-{PYTHON_VERSION}-amd64.exe',
+ 'sha256': '67b5635e80ea51072b87941312d00ec8927c4db9ba18938f7ad2d27b328b95fb',
+ 'size': 26964224,
+}
+
#: Mirrors tried after the canonical URL, in order, when the direct download fails or crawls.
#: GitHub release assets are the slow ones on mainland networks (a report measured 974 s for the
#: 182 MiB LLVM archive); Microsoft's CDN is not, so it is absent here. A mirror only changes
@@ -397,6 +410,32 @@ def llvm_version(clang: Path) -> str:
return m.group(1) if m else (text.splitlines() or [''])[0].strip()
+# ---------------------------------------------------------------- Python
+
+def python_dir() -> Path | None:
+ """The interpreter this app installed for itself, if it is there and runs.
+
+ `find_python` on the front-end side prefers it for the same reason it prefers the app's own
+ git: a machine with no system Python is exactly the machine that ran the in-app installer,
+ and after installing, the interpreter has to be found again without the user editing PATH.
+ """
+ for root in (tools_dir() / f'python-{PYTHON_VERSION}',
+ bundled_tools_dir() / f'python-{PYTHON_VERSION}'):
+ exe = root / 'python.exe'
+ if exe.is_file() and _runs_quiet(exe):
+ return root
+ return None
+
+
+def _runs_quiet(exe: Path) -> bool:
+ try:
+ r = subprocess.run([str(exe), '-c', 'print(1)'], capture_output=True, text=True,
+ timeout=60, **no_window())
+ except (OSError, subprocess.SubprocessError):
+ return False
+ return r.returncode == 0 and (r.stdout or '').strip() == '1'
+
+
# ---------------------------------------------------------------- .NET SDK
def dotnet_dir() -> Path | None:
diff --git a/frontend-qt/tests/test_win.py b/frontend-qt/tests/test_win.py
index f474b1fe..a1413871 100644
--- a/frontend-qt/tests/test_win.py
+++ b/frontend-qt/tests/test_win.py
@@ -1078,6 +1078,98 @@ class ProgressStepTest(unittest.TestCase):
self.assertGreaterEqual(total, 6000)
+class PythonInstallTest(unittest.TestCase):
+ """The interpreter row and the in-app Python installer.
+
+ The report's handheld had no usable interpreter at all, and the row could only answer "too
+ old" — then pip-install into a python that was not there. Now the row says what is true and
+ the fix is a per-user silent install into the app's own tools folder.
+ """
+
+ def test_python_asset_is_pinned(self) -> None:
+ a = tc.PYTHON_ASSET
+ self.assertEqual(len(a['sha256']), 64)
+ self.assertTrue(all(c in '0123456789abcdef' for c in a['sha256']))
+ self.assertIn(tc.PYTHON_VERSION, a['url'])
+ self.assertTrue(a['url'].startswith('https://www.python.org/ftp/python/'))
+ self.assertGreater(a['size'], 20_000_000)
+
+ def test_installer_command_is_per_user_and_silent(self) -> None:
+ """No administrator rights, no PATH changes, lands in the app's own folder."""
+ from nspb_qt.win import fetch
+ with tempfile.TemporaryDirectory() as td:
+ root = Path(td)
+ seen = []
+
+ def fake_run(cmd, **k):
+ seen.append(cmd)
+ return subprocess.CompletedProcess(cmd, 0, '', '')
+
+ exe = root / 'downloads' / tc.PYTHON_ASSET['name']
+ exe.parent.mkdir(parents=True)
+ exe.write_bytes(b'MZ')
+ # first _runs_quiet (the "already installed" check) says no, the one after the
+ # installer says yes: that is the exact sequence install_python goes through
+ with mock.patch.object(fetch, 'download', return_value=exe), \
+ mock.patch.object(fetch.subprocess, 'run', side_effect=fake_run), \
+ mock.patch.object(tc, '_runs_quiet', side_effect=[False, True]):
+ out = fetch.install_python(dest=root, log=lambda s: None)
+ cmd = seen[0]
+ self.assertIn('/quiet', cmd)
+ self.assertIn('InstallAllUsers=0', cmd)
+ self.assertIn('Include_pip=1', cmd)
+ self.assertIn('PrependPath=0', cmd)
+ self.assertTrue(any(str(c).startswith('TargetDir=') and str(root) in str(c)
+ for c in cmd), cmd)
+ self.assertEqual(out, root / f'python-{tc.PYTHON_VERSION}')
+
+ def test_install_python_reports_installer_failure(self) -> None:
+ from nspb_qt.win import fetch
+ with tempfile.TemporaryDirectory() as td:
+ root = Path(td)
+ exe = root / 'downloads' / tc.PYTHON_ASSET['name']
+ exe.parent.mkdir(parents=True)
+ exe.write_bytes(b'MZ')
+ with mock.patch.object(fetch, 'download', return_value=exe), \
+ mock.patch.object(fetch, 'subprocess') as msub, \
+ mock.patch.object(tc, '_runs_quiet', return_value=False):
+ msub.run.return_value = subprocess.CompletedProcess([], 1, 'boom', '')
+ with self.assertRaises(fetch.DownloadError) as cm:
+ fetch.install_python(dest=root, log=lambda s: None)
+ self.assertIn('did not install', str(cm.exception))
+
+ def test_find_python_prefers_the_app_managed_interpreter(self) -> None:
+ """A machine with no system Python must still find the copy the app installed.
+
+ Every probe is mocked so the test does not depend on what this Mac has: the candidate
+ order is the subject, not any real interpreter.
+ """
+ from nspb_qt import platform_util as pu
+ with tempfile.TemporaryDirectory() as td:
+ fake = Path(td) / 'python-3.12.10'
+ fake.mkdir(parents=True)
+ (fake / 'python.exe').write_bytes(b'MZ')
+ with mock.patch.object(pu, 'venv_python', return_value=str(Path(td) / 'no-venv')), \
+ mock.patch.object(pu, '_python_version', return_value='3.12.10'), \
+ mock.patch.object(pu, '_runs', return_value=False):
+ py, ok, _ver = pu.find_python([str(fake / 'python.exe')])
+ self.assertEqual(py, str(fake / 'python.exe'))
+ self.assertFalse(ok) # the packages are not installed in it (yet)
+
+
+class SdkLongPathsTest(unittest.TestCase):
+ """The SDK clone carries core.longpaths: a swiftinterface in the SDK tree tops Windows'
+ 260-character MAX_PATH and the sparse checkout died with "Filename too long"."""
+
+ def test_clone_args_carry_longpaths(self) -> None:
+ import inspect
+ from nspb_qt.win import sdk_fetch
+ src = inspect.getsource(sdk_fetch.clone_sdk)
+ self.assertIn("core.longpaths=true", src)
+ # the sparse-checkout step needs it too: -c applies to one command only
+ self.assertIn("'sparse-checkout', 'set'", src)
+
+
class DotnetTest(unittest.TestCase):
"""The .NET row and its in-app installer.
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index f4098764..50d6d036 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -212,8 +212,13 @@ enum L10n {
"dep.python.missing": ("%@ 缺包", "%@ is missing packages"),
"dep.install.begin": ("开始安装 %@…", "Installing %@…"),
"dep.install.fail": ("安装失败:%@(详情见日志)", "Install failed: %@ (see the log)"),
- "dep.python.old": ("Python %@ 太旧(需要 %@ 或更新);系统的 /usr/bin/python3 没有这些包",
- "Python %@ is too old (need %@ or newer); the system /usr/bin/python3 has none of these packages"),
+ "dep.python.old": ("Python %@ 太旧(需要 3.9 或更新);这个解释器没有构建需要的包",
+ "Python %@ is too old (need 3.9 or newer); it lacks the packages the build needs"),
+ "dep.python.none": ("没找到可用的 Python(%@ 不行)——点右侧「安装」,App 会下载 3.12 并静默装到自己的目录",
+ "No usable Python found (%@ will not run) — press Install and the app fetches 3.12 into its own folder"),
+ "dep.python.downloading": ("正在下载并安装 Python 3.12…(约 26 MB,装到 App 自己的目录)",
+ "Downloading and installing Python 3.12… (about 26 MB, into the app's own folder)"),
+ "dep.python.done": ("Python 已安装:%@", "Python installed: %@"),
// ---- progress ----
"prog.title": ("构建进度", "Build progress"),