[PR #3405] [CLOSED] [Other] macOS setup: install cmake and ninja before a compile #4619

Closed
opened 2026-11-07 15:37:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3405
Author: @Flo5k5
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix-mac-build-tools


📝 Commits (1)

  • 3c316c7 [Other] macOS setup: install cmake and ninja before a compile

📊 Changes

3 files changed (+64 additions, -7 deletions)

View changed files

📝 docs/MAC.md (+2 -2)
📝 metal/setup_mac.py (+21 -5)
📝 tools/test_setup_mac.py (+41 -0)

📄 Description

Problem and result

Fixes #3403. Since a242537 moved cmake and ninja to requirements-build.txt, ./setup.sh on a Mac no longer installs them: metal/setup_mac.py still installs only requirements.txt and expects the build tools to come with it. On a fresh .venv without ninja on PATH, the Metal engine build stops at CMake's 'ninja' '--version'.

With this change, the engine and image encoder builds install the missing pinned helpers from requirements-build.txt into .venv first, and then build.

#3403 (focused fix, no change of defaults)

Approach

build_tools() in metal/setup_mac.py does what setup.py's cmake_build() already does on a PC: it looks for each helper on PATH or next to the venv's Python (find_tool), installs only the missing pins with pip_install, and fails with the same workaround message if they are still not there. It runs right before a compile (build_engine, build_vision), and not when the engine is current, so the runtime install stays free of the build helpers, as a242537 intended. A cmake or ninja already on PATH (Homebrew, for example) is used as before. The step 3 message, the module docstring and docs/MAC.md no longer say that step 3 installs cmake and ninja.

Validation

Passed:

  • python -m unittest tools.test_setup_mac on 3c316c7 (macOS 27.0.1, Python 3.15.0): 28 tests OK. The 4 new BuildTools tests check that a fresh venv gets both pins, that only the missing helper is installed, that requirements.txt carries neither, and that both builds call build_tools() before anything else. On 9ae93f7's setup_mac.py, 3 of them fail (no build_tools).
  • Apple M5 Pro, 64 GB, macOS 27.0.1, fresh checkouts with no .venv, ./setup.sh --update --yes (llama.cpp and metal-cpp copied into third_party/ from an existing checkout at the same pins, STRATA_SETTINGS_FILE and --data-dir pointed at a scratch folder):
    • 9ae93f7, ninja not on PATH, Homebrew cmake on PATH: fails, build-metal/build.log as in #3403 ('ninja' '--version' ... no such file or directory).
    • 0aa3c59 (this change before line wrapping), same PATH: step 4 installs ninja==1.13.2 only and builds build-metal/strata.
    • 3c316c7 (this PR), PATH reduced to /usr/bin:/bin:/usr/sbin:/sbin plus a python3 link, so neither cmake nor ninja: step 4 installs cmake==4.4.3 ninja==1.13.2 and builds build-metal/strata. A second run reports Metal engine: ... (built for this source) and installs nothing.

Failed:

None observed.

Not run:

  • build_vision() on hardware: --update returns before the image encoder step. Only the unit test covers its call to build_tools().
  • The full setup (model download, pack, start): unchanged by this PR and not needed for the failure.
  • CUDA, HIP and SYCL builds: not touched (only metal/setup_mac.py, tools/test_setup_mac.py and docs/MAC.md change).

Limits

An older .venv that already has cmake and ninja behaves as before. The desktop app's Control mode does not run setup_mac.py (its test asserts it), so it is not affected.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3405 **Author:** [@Flo5k5](https://github.com/Flo5k5) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-mac-build-tools` --- ### 📝 Commits (1) - [`3c316c7`](https://github.com/Niko1221/Strata/commit/3c316c7f2737fd737daff5bda2c25b1c60523823) [Other] macOS setup: install cmake and ninja before a compile ### 📊 Changes **3 files changed** (+64 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/MAC.md` (+2 -2) 📝 `metal/setup_mac.py` (+21 -5) 📝 `tools/test_setup_mac.py` (+41 -0) </details> ### 📄 Description ## Problem and result Fixes #3403. Since a242537 moved `cmake` and `ninja` to `requirements-build.txt`, `./setup.sh` on a Mac no longer installs them: `metal/setup_mac.py` still installs only `requirements.txt` and expects the build tools to come with it. On a fresh `.venv` without `ninja` on `PATH`, the Metal engine build stops at CMake's `'ninja' '--version'`. With this change, the engine and image encoder builds install the missing pinned helpers from `requirements-build.txt` into `.venv` first, and then build. ## Related discussion #3403 (focused fix, no change of defaults) ## Approach `build_tools()` in `metal/setup_mac.py` does what `setup.py`'s `cmake_build()` already does on a PC: it looks for each helper on `PATH` or next to the venv's Python (`find_tool`), installs only the missing pins with `pip_install`, and fails with the same workaround message if they are still not there. It runs right before a compile (`build_engine`, `build_vision`), and not when the engine is current, so the runtime install stays free of the build helpers, as a242537 intended. A `cmake` or `ninja` already on `PATH` (Homebrew, for example) is used as before. The step 3 message, the module docstring and `docs/MAC.md` no longer say that step 3 installs cmake and ninja. ## Validation **Passed:** - `python -m unittest tools.test_setup_mac` on 3c316c7 (macOS 27.0.1, Python 3.15.0): 28 tests OK. The 4 new `BuildTools` tests check that a fresh venv gets both pins, that only the missing helper is installed, that `requirements.txt` carries neither, and that both builds call `build_tools()` before anything else. On 9ae93f7's `setup_mac.py`, 3 of them fail (no `build_tools`). - Apple M5 Pro, 64 GB, macOS 27.0.1, fresh checkouts with no `.venv`, `./setup.sh --update --yes` (`llama.cpp` and `metal-cpp` copied into `third_party/` from an existing checkout at the same pins, `STRATA_SETTINGS_FILE` and `--data-dir` pointed at a scratch folder): - 9ae93f7, `ninja` not on `PATH`, Homebrew `cmake` on `PATH`: fails, `build-metal/build.log` as in #3403 (`'ninja' '--version'` ... `no such file or directory`). - 0aa3c59 (this change before line wrapping), same `PATH`: step 4 installs `ninja==1.13.2` only and builds `build-metal/strata`. - 3c316c7 (this PR), `PATH` reduced to `/usr/bin:/bin:/usr/sbin:/sbin` plus a `python3` link, so neither `cmake` nor `ninja`: step 4 installs `cmake==4.4.3 ninja==1.13.2` and builds `build-metal/strata`. A second run reports `Metal engine: ... (built for this source)` and installs nothing. **Failed:** None observed. **Not run:** - `build_vision()` on hardware: `--update` returns before the image encoder step. Only the unit test covers its call to `build_tools()`. - The full setup (model download, pack, start): unchanged by this PR and not needed for the failure. - CUDA, HIP and SYCL builds: not touched (only `metal/setup_mac.py`, `tools/test_setup_mac.py` and `docs/MAC.md` change). ## Limits An older `.venv` that already has cmake and ninja behaves as before. The desktop app's Control mode does not run `setup_mac.py` (its test asserts it), so it is not affected. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4619
No description provided.