Skip to content

The launcher ships its build tools and Python, so a player needs no Homebrew (floor stays macOS 13) - #154

Merged
LNPANDY merged 5 commits into
mainfrom
v0lumehi/bundled-tools-13
Oct 28, 2026
Merged

LNPANDY merged 5 commits into
mainfrom
v0lumehi/bundled-tools-13

Conversation

@v0lumehi

Copy link
Copy Markdown
Collaborator

Re-proposes the bundled build tools from #121 without the macOS 26.6 floor, as promised in our comment there.

Why

The release app carries the build tools and a Python, so a player installs neither Homebrew nor Python. I have talked to a number of people on Instagram and Reddit who gave up during setup, almost always on this part and not on keys or games: installing Homebrew (Terminal, admin password, Command Line Tools), /opt/homebrew not writable, an Intel Homebrew on Apple silicon, a system or Homebrew Python that is too old or refuses pip install (PEP 668), and backports.zstd with no build for Python 3.14. Each is a separate support conversation.

The guided first-run setup (#119/#120) also needs it: Xcode can go through the App Store with one password prompt, but Homebrew's installer needs an interactive sudo session and refuses to run as root, so the onboarding's "preparing in the background" step cannot install it. With the tools inside the app that step is instant and needs no admin rights.

Compatibility

The floor stays at macOS 13. Package.swift (.macOS(.v13)), LSMinimumSystemVersion (13.0) and the tools' MACOSX_DEPLOYMENT_TARGET / CMAKE_OSX_DEPLOYMENT_TARGET (13.0) are unchanged. No current user is left behind.

In NX2Apple.app/Contents/Resources:

Version License From
tools/bin/zstd 1.5.7 BSD-3-Clause OR GPL-2.0 source tarball, sha256-pinned
tools/bin/glslangValidator glslang 16.6.0 BSD-3-Clause, Apache-2.0, MIT, GPL-3.0-or-later (build files) source tarball, sha256-pinned
tools/bin/spirv-cross vulkan-sdk-1.4.363.0 Apache-2.0, MIT source tarball, sha256-pinned (the tag dm/gfx/tools/spirv_cross_bin/build.sh builds)
tools/bin/xcodegen (+ tools/share/xcodegen) 2.46.0 MIT the project's release zip, sha256-pinned
python/ CPython 3.13.18 (python-build-standalone 20261026, install_only arm64) PSF release tarball, sha256-pinned
Python packages lz4 4.4.5, capstone 5.0.9, fonttools 4.68.0, backports.zstd 1.8.0, nsz 5.0.0 and its dependencies (pinned in frontend/tools/bundled-python-requirements.txt) their own pip, --only-binary, at build time

License files go to tools/licenses. The tools are built from source with static libraries and link only /usr/lib (and, for xcodegen, the system's Swift libraries); no Homebrew bottle, no install_name_tool. python-build-standalone's install_only build is minos 11.0 (checked with otool -l on every Mach-O file in it), so it fits the floor; the tools are 13.0.

Size: the app zip grows from 2.6 MB to 52.2 MB (+~50 MB; tools 21 MB and Python 121 MB unpacked, 152 MB app). The release uploads the zip under three names, so the release assets grow three times.

Other changes:

  • BundledTools.swift: the bundled tools/bin and Python from Bundle.main.resourceURL, nil outside a .app (swift run). The dependency rows say "bundled" and are named by the tool; Homebrew's copy is used when the bundle lacks one; the Homebrew row appears only when some tool is neither bundled nor installed.
  • One PATH helper, BuildModel.toolPath, replaces the four build-related PATH strings.
  • Python row: the bundled Python is used when it runs, is 3.12 or newer and imports the packages; a damaged copy falls through to the old search. The build runs it with PYTHONDONTWRITEBYTECODE=1, so nothing is written into the signed app.
  • Update guard: the self-updater reads LSMinimumSystemVersion of the downloaded app and refuses to install a release the running macOS cannot open. Harmless at any floor, and it makes a later floor change safe.
  • bundle_tools.sh ad-hoc signs every Mach-O file under tools and python itself (codesign --deep does not reach code in Resources); check_bundle.sh runs each tool with env -i PATH=/usr/bin:/bin, checks the Python imports (lz4, capstone, fontTools, nsz, zstd), that nothing links outside the system or the bundle, that every Mach-O file has minos of 13.0 or lower, and codesign -v --deep --strict.
  • The workflow runs the bundle steps and also runs on pull requests that touch frontend/ or itself (artifact only, no release).
  • README requirements: the launcher opens on macOS 13 or later; building needs Xcode; NVN games need Xcode 27.1 (macOS 26.6 or later) unless built with --allow-other-metal. The [Xcode](...) 27.1 link that test_ci_toolchain.py reads is kept.

.NET stays as it is (dotnet-install.sh into ~/.dotnet); Xcode, the iOS platform and the Metal toolchain are still the player's. scripts/, dm/ and docs/ are untouched, and python3 scripts/patches.py check passes.

Relation to #150

They complement each other. #150 (merged) gives every dependency that can fail an install a named reason and the command that fixes it; this PR removes the failures that cannot be explained away from a GUI app (Homebrew, Python) by bundling them, and leaves #150's messages for what cannot be bundled: Xcode and its license, the iOS platform, the Metal toolchain, .NET and the network. They meet in ContentView.swift, where detectDepsSync keeps #150's needsIOS and lastError/fixHint rows and gains toolDeps; the merge is resolved here and the two features are independent (a bundled row never fails an install, so it never shows a hint).

Screenshot, left: all bundled tools and Python (rows named by the tool, "bundled", no Homebrew row). Right: the same with .NET failing, which still shows #150's reason and fix under the row.

Tests

  • swift build -c release and swift test in frontend/: 242 tests, 7 skipped, 0 failures (includes BundledToolsTests and the update-guard tests).
  • bundle_tools.sh and check_bundle.sh run locally on an Apple-silicon Mac: every check passes, minos of every Mach-O file is 11.0 (59 files) or 13.0 (3), codesign -v --deep --strict passes on an assembled app.
  • python3 scripts/patches.py check passes; test_ci_toolchain passes.

Not tested: a Mac on macOS 13 itself (checked with otool), an Intel Mac (the app is arm64 only), a game build from the launcher with the bundled tools (no game files here).

Feature, 48h

This is a feature PR: I leave it open for 48 hours for objections before it is treated as ready to merge. It changes the launcher and its release workflow only.

…omebrew

The release app carries zstd, glslangValidator, spirv-cross and xcodegen (Contents/Resources/tools/bin, built from pinned sources for macOS 13 with static libraries) and a relocatable CPython 3.13 with the packages the build scripts import. The dependency check prefers them to Homebrew's and to a system Python and shows 'bundled'; the build's PATH starts with them. Without a bundle (swift run, older builds) nothing changes.
The row says zstd, spirv-cross, xcodegen or glslangValidator with the detail bundled; the brew: label stays on rows that refer to a Homebrew copy (installed there, or missing with the install button).
After unpacking, the new bundle's LSMinimumSystemVersion is compared with the running macOS. Above it, nothing is installed: the update sheet and the status line say that NX2Apple <version> needs macOS <min> and this Mac has <current>, and the running version stays.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Builds can still invoke a rejected bundled Python through PATH, and user-installed packages can shadow bundled dependencies, causing failures despite a working fallback or pinned packages.

2 open issues
What changed in this PR

This PR bundles build tools and Python with the macOS launcher, removing Homebrew and Python installation from player setup while retaining the macOS 13 minimum.

Changes:

  • Adds pinned tools and Python packages, with bundle assembly and validation in CI.
  • Prefers bundled dependencies in detection and build environments, preserving external fallbacks.
  • Blocks incompatible self-updates and adds tests, localized messages, and setup documentation.
File Description
README.zh-CN.md Updates Chinese setup requirements.
README.md Clarifies bundled dependencies and macOS requirements.
frontend/​tools/​check_bundle.sh Checks tool execution, linkage, compatibility, and optional signing.
frontend/​tools/​bundled-python-requirements.txt Pins bundled Python packages.
frontend/​tools/​bundle_tools.sh Assembles and signs bundled tools and Python.
frontend/​Tests/​NSPortBuilderTests/​BundledToolsTests.swift Tests bundle discovery, dependency rows, PATH, and Python selection.
frontend/​Tests/​NSPortBuilderTests/​AppUpdateTests.swift Tests OS-version comparison and incompatible-update rejection.
frontend/​Sources/​NSPortBuilder/​UpdateSheet.swift Displays update failures without closing the sheet.
frontend/​Sources/​NSPortBuilder/​Localization.swift Adds bundled-tool labels and compatibility messages.
frontend/​Sources/​NSPortBuilder/​ContentView.swift Integrates bundled dependencies and update compatibility checks.
frontend/​Sources/​NSPortBuilder/​BundledTools.swift Centralizes bundle discovery and PATH construction.
frontend/​Sources/​NSPortBuilder/​AppUpdate.swift Reads and compares an update’s minimum macOS version.
frontend/​README.md Documents bundled tools and manual bundle checks.
.github/​workflows/​build-mac-app.yml Assembles and validates bundles for releases and relevant pull requests.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants