madspace install.py: add --clean for a rebuild from scratch - #189
Open
oliviermattelaer wants to merge 2 commits into
Open
oliviermattelaer wants to merge 2 commits into
oliviermattelaer wants to merge 2 commits into
Conversation
A rebuild reuses the CMake tree in madspace/build and is incremental, which is what keeps it down to seconds instead of recompiling madspace and its vendored OpenBLAS. When that tree is in the way (toolchain change, half-finished build) the only cure was a hand-written `rm -rf madspace/build madspace/install`. --clean does exactly that and then installs as usual; `install madspace --clean` at the MG7 prompt works too, since the arguments are passed through. It is deliberately opt-in: cleaning on every `install madspace` would turn the routine post-`git pull` rebuild -- the one the source-hash warning in launch.py asks for -- into a full one. install_settings.json moves out of build/ to madspace/install_settings.json, so a clean resets the build without also forgetting how the user wants madspace built: otherwise --clean --yes would silently fall back to the platform defaults, the failure mode just fixed for the compile flags. The old location is still read, so an existing installation keeps its choices. main() reads the settings before wiping, for the same reason. The installer also wipes the build tree by itself when CMakeCache.txt shows that reusing it cannot work -- a compiler named by CC/CXX or an interpreter that is no longer the current one, both of which CMake can only answer with "you have changed variables that require your cache to be deleted". The check is deliberately narrow: anything CMake can pick up by reconfiguring must not turn an ordinary rebuild into a full one. That one removes only build/, not the install. 16 more tests in tests/unit_tests/various/test_madspace_install.py (33 total, still nothing built), and the madspace installation docs describe --clean and the per-option precedence. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…n) into claude/madspace-install-clean
Base automatically changed from
claude/madspace-install-flag-precedence
to
main
September 20, 2026 19:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #176 (based on its branch, so the diff stays reviewable; GitHub retargets this to
mainwhen #176 merges).Why
A rebuild reuses the CMake tree in
madspace/build, which is what keeps it incremental — seconds, instead of recompiling madspace and its vendored OpenBLAS. When that tree is in the way (a toolchain change, a half-finished build), the only cure was a hand-writtenrm -rf madspace/build madspace/installthat users had to know.--cleanDeletes
madspace/buildandmadspace/install, then installs as usual:install madspace --cleanat the MG7 prompt works too, since the arguments are passed straight through.It is deliberately opt-in. Cleaning on every
install madspacewould turn the routine rebuild after agit pull— the one the source-hash warning inlaunch.pyasks for — into a full one, which is the slow path for the most common case.The settings had to move
install_settings.jsonlived insidemadspace/build, so a naive wipe erased it and the next--yesrebuild silently fell back to the platform defaults — the failure mode #176 just fixed, through a different door. So:madspace/install_settings.json, outside both cleaned directories (and gitignored);main()reads the settings before wiping.--clean --yestherefore still rebuilds the remembered configuration, from scratch.Narrow auto-clean
The installer also wipes the build tree by itself when
CMakeCache.txtshows that reusing it cannot work: a compiler named byCC/CXX, or an interpreter, that is no longer the current one. CMake answers both with "you have changed variables that require your cache to be deleted".The check is deliberately narrow — anything CMake can pick up by reconfiguring is not reported, so ordinary rebuilds stay incremental. The compilers are only compared when
CC/CXXname them explicitly; without those, CMake runs its own search and the cached path is not something to second-guess. This auto-clean removes onlybuild/, never the install.Checked against a real build tree on macOS (clang, direnv venv): no staleness reported; a changed
CXXis caught.Tests
16 more in
tests/unit_tests/various/test_madspace_install.py, 33 in total, nothing built. They coverclean_install_dirs, the settings round-trip across a clean, the legacy-location fallback,CMakeCache.txtparsing andstale_build_reason, plusmain()with--cleanand with a stale cache.Three mutations of the source, each caught:
build/→ the location-invariant test fails;./tests/test_manager.py test_madspace_install -t0→Ran 33 tests, OK.Not included: an
--uninstall(wipe and stop) — a separate thing, happy to add it if wanted.🤖 Generated with Claude Code