Skip to content

mfc.sh: add --prebuilt-prefix for running against prebuilt binaries#1444

Merged
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:spack-prebuilt-prefix
May 17, 2026
Merged

mfc.sh: add --prebuilt-prefix for running against prebuilt binaries#1444
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:spack-prebuilt-prefix

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Adds support for running mfc.sh run and mfc.sh test against an externally-installed MFC (e.g. a Spack install prefix) instead of rebuilding from source.

Motivation

A separate Spack package for MFC is being prepared. Without first-class support in MFC for "use my prebuilt binaries from /bin", the Spack recipe has to ship a ~100-line shell wrapper that fakes an MFC working tree via cache-dir symlinks and aspirational env vars (MFC_PREBUILT_BIN_DIR and friends) that no MFC code actually reads. Reviewers on the Spack side will (rightly) push back on that. This change moves the "find installed binaries + skip the build steps" logic where it belongs: inside MFC.

Changes

  • New CLI flag --prebuilt-prefix=<PATH> on mfc.sh run and mfc.sh test. Also settable via MFC_PREBUILT_PREFIX environment variable (CLI wins).
  • When set:
    • Target.is_buildable() returns False for every target (implies --no-build).
    • Target.get_install_binpath() resolves to <prefix>/bin/<target> instead of <cwd>/build/install/<slug>/bin/<target>.
    • toolchain/bootstrap/python.sh skips venv creation; caller is responsible for putting python3 + toolchain deps + the mfc package on PYTHONPATH.
    • mfc.sh's trailing deactivate call is now guarded (no-op when there's no venv to deactivate).
  • Zero behavior change when the env var is unset and the flag is absent.

Testing

Local:

  • ./mfc.sh format -j 8 clean
  • ./mfc.sh precheck -j 8 6/6 pass (formatting, spelling, toolchain lint, source lint, doc refs, parameter docs)
  • --prebuilt-prefix shows in both run --help and test --help
  • get_prebuilt_prefix() precedence verified: CLI > env > None, empty-string CLI falls back to env
  • MFC_PREBUILT_PREFIX=/tmp/fake ./mfc.sh run --help runs cleanly, skips venv

End-to-end MFC build + test verification is what this PR's CI will cover (local build blocked by an unrelated apple-clang 21 + ncurses toolchain issue).

Follow-up

After this merges, the planned spack-packages PR for mfc collapses from ~360 lines (with embedded shell wrapper) to ~120 lines and just sets MFC_PREBUILT_PREFIX=<prefix> in setup_run_environment.

Lets 'mfc.sh run' and 'mfc.sh test' use an externally-installed MFC
(e.g. a Spack install prefix) instead of rebuilding from source.
Also settable via the MFC_PREBUILT_PREFIX environment variable, so
package managers can flip the mode in setup_run_environment.

When set:
  - is_buildable() returns False (implies --no-build) for all targets
  - get_install_binpath() resolves to <prefix>/bin/<target> instead of
    <root>/build/install/<slug>/bin/<target>
  - toolchain/bootstrap/python.sh skips venv creation; the caller is
    responsible for putting python3 + toolchain deps + the mfc package
    on PYTHONPATH

Zero behavior change when the env var is unset and the flag is absent.
@sbryngelson sbryngelson marked this pull request as ready for review May 17, 2026 03:14
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@sbryngelson sbryngelson merged commit dd231ae into MFlowCode:master May 17, 2026
41 of 71 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.31%. Comparing base (7081882) to head (0d6efe1).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1444   +/-   ##
=======================================
  Coverage   61.31%   61.31%           
=======================================
  Files          72       72           
  Lines       19771    19771           
  Branches     2852     2852           
=======================================
  Hits        12123    12123           
  Misses       5699     5699           
  Partials     1949     1949           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sbryngelson added a commit to sbryngelson/spack-packages that referenced this pull request May 17, 2026
mfc.sh's build path creates a Python venv (toolchain/bootstrap/python.sh
calls `python3 -m venv build/venv` and pip-installs the toolchain into
it). On most Linux distros the venv module ships with python's stdlib,
but spack's python-venv package makes the dependency explicit so the
build cannot fail on systems where venv support is split off.

Run-time does not need this dep because spack's setup_run_environment
sets MFC_PREBUILT_PREFIX, which makes mfc.sh skip venv setup entirely
(MFlowCode/MFC#1444).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant