From 240283fce2ce208ddc8214954acd31e00b6949d1 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:11:10 -0500 Subject: [PATCH 01/17] Change MFC version to 5.1.0 and update dependencies Update MFC formula to use version 5.1.0 and add new dependencies. --- Formula/mfc.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Formula/mfc.rb b/Formula/mfc.rb index b9b9cd3..a9be92a 100644 --- a/Formula/mfc.rb +++ b/Formula/mfc.rb @@ -6,8 +6,8 @@ class Mfc < Formula desc "Exascale multiphase/multiphysics compressible flow solver" homepage "https://mflowcode.github.io/" - url "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" - sha256 "229ba4532d9b31e54e7db67cc6c6a4c069034bb143be7c57cba31c5a56fe6a0b" + url "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.0.tar.gz" + sha256 "4684bee6a529287f243f8929fb7edb0dfebbb04df7c1806459761c9a6c9261cf" license "MIT" head "https://github.com/MFlowCode/MFC.git", branch: "master" @@ -29,7 +29,7 @@ def install # Create Python virtual environment inside libexec (inside Cellar for proper bottling) venv = libexec/"venv" system Formula["python@3.12"].opt_bin/"python3.12", "-m", "venv", venv - system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel", "setuptools-scm" + system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel", "setuptools-scm", "hatchling", "hatch-vcs" # Install Cantera from PyPI using pre-built wheel (complex package, doesn't need custom flags) # Cantera has CMake compatibility issues when building from source with newer CMake versions @@ -42,8 +42,9 @@ def install # Keep toolchain in buildpath for now - mfc.sh needs it there # # MFC's toolchain uses VCS-derived versioning (via Hatch/hatch-vcs) and Homebrew builds from - # GitHub release tarballs without a .git directory. Scope pretend-version env vars tightly - # to avoid polluting subsequent pip installs. + # GitHub release tarballs without a .git directory. Use --no-build-isolation so the build + # backend can see our environment variables, and set SETUPTOOLS_SCM_PRETEND_VERSION which + # hatch-vcs respects when VCS metadata is unavailable. pretend_env = { "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version.to_s, "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version.to_s, @@ -56,7 +57,7 @@ def install end begin - system venv/"bin/pip", "install", "-e", buildpath/"toolchain" + system venv/"bin/pip", "install", "--no-build-isolation", "-e", buildpath/"toolchain" ensure pretend_env.each_key do |k| if saved_env[k].nil? From 945d5a728b962cf2151d4fea0419d8be7321f363 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:11:46 -0500 Subject: [PATCH 02/17] Update push event configuration in bottle.yml Remove branch restriction for push events. --- .github/workflows/bottle.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index d3b7f8e..53c1b78 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -2,8 +2,6 @@ name: Bottle on: push: - branches: - - main paths: - "Formula/**" - ".github/workflows/bottle.yml" From 5ecd5cb3bed7be0647d1993f8c79eeb8e424d3c9 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:18:59 -0500 Subject: [PATCH 03/17] Update pip install command to include 'editables' --- Formula/mfc.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Formula/mfc.rb b/Formula/mfc.rb index a9be92a..6696e8b 100644 --- a/Formula/mfc.rb +++ b/Formula/mfc.rb @@ -29,8 +29,11 @@ def install # Create Python virtual environment inside libexec (inside Cellar for proper bottling) venv = libexec/"venv" system Formula["python@3.12"].opt_bin/"python3.12", "-m", "venv", venv - system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel", "setuptools-scm", "hatchling", "hatch-vcs" - + system venv/"bin/pip", "install", "--upgrade", + "pip", "setuptools", "wheel", + "setuptools-scm", + "hatchling", "hatch-vcs", + "editables" # Install Cantera from PyPI using pre-built wheel (complex package, doesn't need custom flags) # Cantera has CMake compatibility issues when building from source with newer CMake versions # Match the version constraint from toolchain/pyproject.toml From 868402e3933b9eb1a232bf201133a2808681db68 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:27:03 -0500 Subject: [PATCH 04/17] Update bottle.yml --- .github/workflows/bottle.yml | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 53c1b78..04802ae 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -32,40 +32,21 @@ jobs: id: meta run: | set -euo pipefail - FORMULA="Formula/mfc.rb" - - # Take the *last* matching URL (guards against accidental duplicates) + URL="$( - grep -E '^\s*url\s+"https://github.com/.*/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz"' "${FORMULA}" \ - | sed -E 's/^\s*url\s+"([^"]+)".*/\1/' \ + grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \ | tail -n 1 )" - - if [[ -z "${URL}" ]]; then - echo "Could not extract release tarball URL from ${FORMULA}" >&2 - echo "Expected a line like: url \"https://github.com///archive/refs/tags/vX.Y.Z.tar.gz\"" >&2 - exit 1 - fi - + VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')" - if [[ -z "${VERSION}" ]]; then - echo "Could not parse version from URL: ${URL}" >&2 - exit 1 - fi - TAG="mfc-${VERSION}" ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" - + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" - - echo "Formula URL: ${URL}" - echo "Formula version: ${VERSION}" - echo "Release tag: ${TAG}" - echo "Bottle root_url: ${ROOT_URL}" - + - name: Install formula with --build-bottle (from checked-out formula via temp tap) run: | set -euo pipefail From a7110bd55c02f914aa77c66bd4b9bf5f6bdbd7fb Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:31:22 -0500 Subject: [PATCH 05/17] Output root_url in bottle.yml workflow Add echo command to output root_url in workflow --- .github/workflows/bottle.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 04802ae..b97e0f4 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -46,7 +46,10 @@ jobs: echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" - + + - run: | + echo "root_url=${{ steps.meta.outputs.root_url }}" + - name: Install formula with --build-bottle (from checked-out formula via temp tap) run: | set -euo pipefail From d6f59325938e99b1f1434e1eaf0f8827b579eccb Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:38:06 -0500 Subject: [PATCH 06/17] Refactor GitHub Actions workflow for bottle creation Removed specific path triggers for push events and updated formula installation steps to use a temporary tap. --- .github/workflows/bottle.yml | 109 +++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 38 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index b97e0f4..15b8116 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -2,9 +2,6 @@ name: Bottle on: push: - paths: - - "Formula/**" - - ".github/workflows/bottle.yml" workflow_dispatch: permissions: @@ -33,48 +30,67 @@ jobs: run: | set -euo pipefail FORMULA="Formula/mfc.rb" - + URL="$( grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \ | tail -n 1 )" - + + if [[ -z "${URL}" ]]; then + echo "Could not extract release tarball URL from ${FORMULA}" >&2 + exit 1 + fi + VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')" + if [[ -z "${VERSION}" ]]; then + echo "Could not parse version from URL: ${URL}" >&2 + exit 1 + fi + TAG="mfc-${VERSION}" ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" - + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" - - - run: | - echo "root_url=${{ steps.meta.outputs.root_url }}" - - - name: Install formula with --build-bottle (from checked-out formula via temp tap) + + echo "Formula URL: ${URL}" + echo "Formula version: ${VERSION}" + echo "Release tag: ${TAG}" + echo "Bottle root_url: ${ROOT_URL}" + + - name: Create temp tap with checked-out formula run: | set -euo pipefail - - echo "Installing mfc with --build-bottle from checked-out Formula/mfc.rb via a temporary local tap..." - + # brew tap-new needs git identity sometimes git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - + # Create a local tap and copy the formula into Homebrew's tap location brew tap-new mflowcode/local TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" mkdir -p "${TAP_DIR}/Formula" cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" - - # Homebrew may exit non-zero due to dylib fixup issues in Python wheels, + + echo "Temp tap formula:" + ls -la "${TAP_DIR}/Formula/mfc.rb" + + - name: Install formula with --build-bottle (temp tap) + run: | + set -euo pipefail + + echo "Installing mfc with --build-bottle (allowing non-fatal dylib fixup failures)..." + + # Homebrew may exit non-zero due to dylib ID fixup issues in Python wheels, # even though the formula actually installed correctly. Treat that as # non-fatal as long as the formula is present. set +e brew install --build-bottle mflowcode/local/mfc 2>&1 | tee /tmp/brew-install.log brew_exit_code=$? set -e - - if brew list mfc &>/dev/null; then + + if brew list mflowcode/local/mfc &>/dev/null; then echo "✅ mfc installed successfully (ignoring dylib fixup warnings)" else echo "❌ mfc installation failed; propagating brew exit code" @@ -87,7 +103,7 @@ jobs: echo "Running a simple test case (1D Sod shock tube) on ${{ matrix.os }}..." TESTDIR=$(mktemp -d) - cp "$(brew --prefix mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/" + cp "$(brew --prefix mflowcode/local/mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/" cd "$TESTDIR" mfc case.py -j 1 @@ -98,26 +114,33 @@ jobs: - name: Basic installation verification run: | set -euo pipefail + PREFIX="$(brew --prefix mflowcode/local/mfc)" + echo "1. Checking binaries..." - test -x "$(brew --prefix mfc)/bin/pre_process" - test -x "$(brew --prefix mfc)/bin/simulation" - test -x "$(brew --prefix mfc)/bin/post_process" - test -x "$(brew --prefix mfc)/bin/mfc" + test -x "${PREFIX}/bin/pre_process" + test -x "${PREFIX}/bin/simulation" + test -x "${PREFIX}/bin/post_process" + test -x "${PREFIX}/bin/mfc" + echo "2. Checking toolchain..." - test -d "$(brew --prefix mfc)/toolchain" + test -d "${PREFIX}/toolchain" + echo "3. Checking Python venv..." - test -d "$(brew --prefix mfc)/libexec/venv" - test -x "$(brew --prefix mfc)/libexec/venv/bin/python" + test -d "${PREFIX}/libexec/venv" + test -x "${PREFIX}/libexec/venv/bin/python" + echo "4. Checking examples..." - test -d "$(brew --prefix mfc)/examples" + test -d "${PREFIX}/examples" + echo "5. Testing mfc command..." mfc --help + echo "✅ All verification checks passed on ${{ matrix.os }}" - - name: Build bottle + - name: Build bottle (temp tap formula) run: | set -euo pipefail - brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mfc + brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mflowcode/local/mfc ls -1 *.bottle.* - name: Upload bottle artifacts @@ -145,33 +168,43 @@ jobs: id: meta run: | set -euo pipefail - FORMULA="Formula/mfc.rb" - + URL="$( - grep -E '^\s*url\s+"https://github.com/.*/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz"' "${FORMULA}" \ - | sed -E 's/^\s*url\s+"([^"]+)".*/\1/' \ + grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \ | tail -n 1 )" - + if [[ -z "${URL}" ]]; then echo "Could not extract release tarball URL from ${FORMULA}" >&2 exit 1 fi - + VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')" if [[ -z "${VERSION}" ]]; then echo "Could not parse version from URL: ${URL}" >&2 exit 1 fi - + TAG="mfc-${VERSION}" ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" - + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" + - name: Create temp tap with checked-out formula (merge job) + run: | + set -euo pipefail + + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + brew tap-new mflowcode/local + TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" + mkdir -p "${TAP_DIR}/Formula" + cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" + - name: Download all bottle artifacts uses: actions/download-artifact@v4 with: From 19bef6d82ca66396bb37dc1cb57bcac50cf2ca60 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:44:13 -0500 Subject: [PATCH 07/17] Update mfc.rb --- Formula/mfc.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/mfc.rb b/Formula/mfc.rb index 6696e8b..4737795 100644 --- a/Formula/mfc.rb +++ b/Formula/mfc.rb @@ -6,8 +6,8 @@ class Mfc < Formula desc "Exascale multiphase/multiphysics compressible flow solver" homepage "https://mflowcode.github.io/" - url "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.0.tar.gz" - sha256 "4684bee6a529287f243f8929fb7edb0dfebbb04df7c1806459761c9a6c9261cf" + url "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" + sha256 "229ba4532d9b31e54e7db67cc6c6a4c069034bb143be7c57cba31c5a56fe6a0b" license "MIT" head "https://github.com/MFlowCode/MFC.git", branch: "master" From b87268d54e6616ed9b5a3ff8efbbd267883a05c9 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 00:55:22 -0500 Subject: [PATCH 08/17] Add tarball download test step in bottle.yml Added a step to test tarball download in the workflow. --- .github/workflows/bottle.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 15b8116..5e6c5d2 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -24,6 +24,11 @@ jobs: - name: Set up Homebrew uses: Homebrew/actions/setup-homebrew@master + + - name: Test tarball download + run: | + curl -I "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" + curl -L "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" | shasum -a 256 - name: Determine version and root URL (from checked-out formula) id: meta From ebbfcb212695bcb944e4bdf38b846f1361897ae5 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 01:04:30 -0500 Subject: [PATCH 09/17] Add versioning environment variables for mfc.sh Set environment variables for versioning in mfc.sh. --- Formula/mfc.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Formula/mfc.rb b/Formula/mfc.rb index 4737795..69d6014 100644 --- a/Formula/mfc.rb +++ b/Formula/mfc.rb @@ -78,7 +78,12 @@ def install # Now build MFC with pre-configured venv # Set VIRTUAL_ENV so mfc.sh uses existing venv instead of creating new one ENV["VIRTUAL_ENV"] = venv - + + # Also set pretend-version env vars for mfc.sh in case it tries to reinstall toolchain + ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC"] = version.to_s + ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc"] = version.to_s + ENV["SETUPTOOLS_SCM_PRETEND_VERSION"] = version.to_s + # Build MFC using pre-configured venv # Must run from buildpath (MFC root directory) where toolchain/ exists Dir.chdir(buildpath) do From 1d0c8bbfa3b3b37b6371b874f6956339f66c8af9 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 01:20:48 -0500 Subject: [PATCH 10/17] Refactor bottle workflow for git config and brew command Updated the bottle workflow to configure git for merges and adjusted the brew bottle command to include root URL. --- .github/workflows/bottle.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 5e6c5d2..938c1ec 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -198,18 +198,12 @@ jobs: echo "tag=${TAG}" >> "$GITHUB_OUTPUT" echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" - - name: Create temp tap with checked-out formula (merge job) + - name: Configure git for bottle merge run: | set -euo pipefail - git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - brew tap-new mflowcode/local - TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" - mkdir -p "${TAP_DIR}/Formula" - cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" - - name: Download all bottle artifacts uses: actions/download-artifact@v4 with: @@ -262,7 +256,7 @@ jobs: BEFORE_SHA=$(git rev-parse HEAD) echo "HEAD before merge: ${BEFORE_SHA}" - brew bottle --merge --write "${JSON_BOTTLES[@]}" + brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" AFTER_SHA=$(git rev-parse HEAD) echo "HEAD after merge: ${AFTER_SHA}" From cf30bbc68a6704d33042ef6790baacdc186b1616 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 08:15:40 -0500 Subject: [PATCH 11/17] Fix formatting in bottle.yml for GITHUB_TOKEN From 3d8293b9eb493c5a6734278a783d529cf3032f38 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 08:17:17 -0500 Subject: [PATCH 12/17] Refactor pip install commands in mfc.rb --- Formula/mfc.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Formula/mfc.rb b/Formula/mfc.rb index 3ae4da1..69d6014 100644 --- a/Formula/mfc.rb +++ b/Formula/mfc.rb @@ -29,13 +29,11 @@ def install # Create Python virtual environment inside libexec (inside Cellar for proper bottling) venv = libexec/"venv" system Formula["python@3.12"].opt_bin/"python3.12", "-m", "venv", venv - system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel", "setuptools-scm", "hatchling", "hatch-vcs", "editables" - # Install Cantera from PyPI using pre-built wheel (complex package, doesn't need custom flags) # Cantera has CMake compatibility issues when building from source with newer CMake versions # Match the version constraint from toolchain/pyproject.toml @@ -47,8 +45,9 @@ def install # Keep toolchain in buildpath for now - mfc.sh needs it there # # MFC's toolchain uses VCS-derived versioning (via Hatch/hatch-vcs) and Homebrew builds from - # GitHub release tarballs without a .git directory. Scope pretend-version env vars tightly - # to avoid polluting subsequent pip installs. + # GitHub release tarballs without a .git directory. Use --no-build-isolation so the build + # backend can see our environment variables, and set SETUPTOOLS_SCM_PRETEND_VERSION which + # hatch-vcs respects when VCS metadata is unavailable. pretend_env = { "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version.to_s, "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version.to_s, @@ -61,7 +60,7 @@ def install end begin - system venv/"bin/pip", "install", "-e", buildpath/"toolchain" + system venv/"bin/pip", "install", "--no-build-isolation", "-e", buildpath/"toolchain" ensure pretend_env.each_key do |k| if saved_env[k].nil? @@ -79,7 +78,12 @@ def install # Now build MFC with pre-configured venv # Set VIRTUAL_ENV so mfc.sh uses existing venv instead of creating new one ENV["VIRTUAL_ENV"] = venv - + + # Also set pretend-version env vars for mfc.sh in case it tries to reinstall toolchain + ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC"] = version.to_s + ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc"] = version.to_s + ENV["SETUPTOOLS_SCM_PRETEND_VERSION"] = version.to_s + # Build MFC using pre-configured venv # Must run from buildpath (MFC root directory) where toolchain/ exists Dir.chdir(buildpath) do @@ -349,4 +353,4 @@ def caveats assert_path_exists testpath_case/"silo_hdf5" assert_predicate testpath_case/"silo_hdf5", :directory? end -end \ No newline at end of file +end From b1c32d0f49711aca47846de174cf4b7e99c09de6 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 08:53:28 -0500 Subject: [PATCH 13/17] Add brew tap step for mflowcode/local --- .github/workflows/bottle.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 938c1ec..47ffe32 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -238,6 +238,14 @@ jobs: echo "Bottles ready for upload:" ls -1 bottles/*.bottle.* + - name: Tap this checkout as mflowcode/local (so brew can find mflowcode/local/mfc) + shell: bash + run: | + set -euo pipefail + brew tap mflowcode/local "${GITHUB_WORKSPACE}" --force-auto-update || true + brew tap --list | grep -q '^mflowcode/local$' + brew info mflowcode/local/mfc + - name: Merge bottle metadata into formula id: merge run: | From 18ccb8e81e04fd1de2a831a7f4d636b29f5cb904 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 09:04:32 -0500 Subject: [PATCH 14/17] Refactor bottle metadata merge step in workflow --- .github/workflows/bottle.yml | 75 ++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 47ffe32..915ea23 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -242,40 +242,49 @@ jobs: shell: bash run: | set -euo pipefail - brew tap mflowcode/local "${GITHUB_WORKSPACE}" --force-auto-update || true - brew tap --list | grep -q '^mflowcode/local$' + + # Ensure a clean state if a previous run left the tap installed + brew untap mflowcode/local >/dev/null 2>&1 || true + + # Tap the checked-out repository as a local tap + brew tap mflowcode/local "${GITHUB_WORKSPACE}" + + # Verify the tap exists (brew tap with no args lists taps) + brew tap | grep -q '^mflowcode/local$' + + # Verify the formula resolves brew info mflowcode/local/mfc - - - name: Merge bottle metadata into formula - id: merge - run: | - set -euo pipefail - - JSON_BOTTLES=(bottles/*.bottle*.json) - if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then - echo "No bottle metadata (*.bottle*.json) found in bottles/" - ls -la bottles/ - exit 1 - fi - - echo "Merging bottle metadata from:" - printf '%s\n' "${JSON_BOTTLES[@]}" - - BEFORE_SHA=$(git rev-parse HEAD) - echo "HEAD before merge: ${BEFORE_SHA}" - - brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" - - AFTER_SHA=$(git rev-parse HEAD) - echo "HEAD after merge: ${AFTER_SHA}" - - if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then - echo "✅ New bottle commit created by brew bottle --write" - echo "bottle_updated=true" >> "$GITHUB_OUTPUT" - else - echo "ℹ️ No new commit (bottles unchanged or already present)" - echo "bottle_updated=false" >> "$GITHUB_OUTPUT" - fi + + - name: Merge bottle metadata into formula + id: merge + run: | + set -euo pipefail + + JSON_BOTTLES=(bottles/*.bottle*.json) + if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then + echo "No bottle metadata (*.bottle*.json) found in bottles/" + ls -la bottles/ + exit 1 + fi + + echo "Merging bottle metadata from:" + printf '%s\n' "${JSON_BOTTLES[@]}" + + BEFORE_SHA=$(git rev-parse HEAD) + echo "HEAD before merge: ${BEFORE_SHA}" + + brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" + + AFTER_SHA=$(git rev-parse HEAD) + echo "HEAD after merge: ${AFTER_SHA}" + + if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then + echo "✅ New bottle commit created by brew bottle --write" + echo "bottle_updated=true" >> "$GITHUB_OUTPUT" + else + echo "ℹ️ No new commit (bottles unchanged or already present)" + echo "bottle_updated=false" >> "$GITHUB_OUTPUT" + fi - name: Push bottle updates if changed if: steps.merge.outputs.bottle_updated == 'true' From 004e2baa6da5b2472ab616641b81c02a41c2d496 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 09:33:16 -0500 Subject: [PATCH 15/17] Update GitHub Actions workflow for bottle management --- .github/workflows/bottle.yml | 106 +++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 915ea23..1b2253b 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -25,6 +25,13 @@ jobs: - name: Set up Homebrew uses: Homebrew/actions/setup-homebrew@master + - name: Ensure no conflicting taps provide mfc + shell: bash + run: | + set -euo pipefail + brew untap mflowcode/mfc >/dev/null 2>&1 || true + brew untap mflowcode/local >/dev/null 2>&1 || true + - name: Test tarball download run: | curl -I "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" @@ -238,79 +245,82 @@ jobs: echo "Bottles ready for upload:" ls -1 bottles/*.bottle.* - - name: Tap this checkout as mflowcode/local (so brew can find mflowcode/local/mfc) + - name: Ensure no conflicting taps provide mfc (merge job) shell: bash run: | set -euo pipefail - - # Ensure a clean state if a previous run left the tap installed + brew untap mflowcode/mfc >/dev/null 2>&1 || true brew untap mflowcode/local >/dev/null 2>&1 || true - # Tap the checked-out repository as a local tap - brew tap mflowcode/local "${GITHUB_WORKSPACE}" + - name: Create temp tap for merge and copy formula into it + shell: bash + run: | + set -euo pipefail + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" - # Verify the tap exists (brew tap with no args lists taps) - brew tap | grep -q '^mflowcode/local$' + brew tap-new mflowcode/local + TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" + mkdir -p "${TAP_DIR}/Formula" + cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" - # Verify the formula resolves brew info mflowcode/local/mfc - - name: Merge bottle metadata into formula - id: merge - run: | - set -euo pipefail + - name: Merge bottle metadata into formula + id: merge + shell: bash + run: | + set -euo pipefail - JSON_BOTTLES=(bottles/*.bottle*.json) - if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then - echo "No bottle metadata (*.bottle*.json) found in bottles/" - ls -la bottles/ - exit 1 - fi + JSON_BOTTLES=(bottles/*.bottle*.json) + if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then + echo "No bottle metadata (*.bottle*.json) found in bottles/" + ls -la bottles/ + exit 1 + fi - echo "Merging bottle metadata from:" - printf '%s\n' "${JSON_BOTTLES[@]}" + TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" - BEFORE_SHA=$(git rev-parse HEAD) - echo "HEAD before merge: ${BEFORE_SHA}" + echo "Merging bottle metadata from:" + printf '%s\n' "${JSON_BOTTLES[@]}" - brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" + brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" - AFTER_SHA=$(git rev-parse HEAD) - echo "HEAD after merge: ${AFTER_SHA}" + # Copy the updated formula back into this checkout so git add works here + cp "${TAP_DIR}/Formula/mfc.rb" Formula/mfc.rb - if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then - echo "✅ New bottle commit created by brew bottle --write" - echo "bottle_updated=true" >> "$GITHUB_OUTPUT" - else - echo "ℹ️ No new commit (bottles unchanged or already present)" - echo "bottle_updated=false" >> "$GITHUB_OUTPUT" - fi + if git diff --quiet -- Formula/mfc.rb; then + echo "bottle_updated=false" >> "$GITHUB_OUTPUT" + else + echo "bottle_updated=true" >> "$GITHUB_OUTPUT" + fi + - name: Commit formula update if changed + if: steps.merge.outputs.bottle_updated == 'true' + shell: bash + run: | + set -euo pipefail + git add Formula/mfc.rb + if git diff --cached --quiet; then + echo "No changes staged; skipping commit." + exit 0 + fi + git commit -m "mfc: bottles for v${{ steps.meta.outputs.version }}" + - name: Push bottle updates if changed if: steps.merge.outputs.bottle_updated == 'true' + shell: bash run: | set -euo pipefail - - echo "Pushing bottle update commit..." - git log -1 --stat - - git config --local --unset-all http.https://github.com/.extraheader || true - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git - + git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" git push origin HEAD:main - - name: Create or update GitHub Release + - name: Create/update release and upload bottles uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.meta.outputs.tag }} name: MFC bottles ${{ steps.meta.outputs.version }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload bottles to Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ steps.meta.outputs.tag }} files: bottles/*.bottle.* + fail_on_unmatched_files: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} From 3ef1347167b62e992fba3639e166681be45cfed7 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 09:50:35 -0500 Subject: [PATCH 16/17] Refactor Homebrew workflow for mfc installation Updated Homebrew workflow to use the correct tap for mfc and removed temporary tap creation steps. --- .github/workflows/bottle.yml | 134 +++++++++-------------------------- 1 file changed, 35 insertions(+), 99 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index 1b2253b..e5e2a87 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -24,40 +24,29 @@ jobs: - name: Set up Homebrew uses: Homebrew/actions/setup-homebrew@master - - - name: Ensure no conflicting taps provide mfc + + # IMPORTANT: do NOT untap mflowcode/mfc in this job. setup-homebrew manages it and + # its post-cleanup expects the tap directory to exist. + - name: Ensure no leftover local tap shell: bash run: | set -euo pipefail - brew untap mflowcode/mfc >/dev/null 2>&1 || true brew untap mflowcode/local >/dev/null 2>&1 || true - - - name: Test tarball download - run: | - curl -I "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" - curl -L "https://github.com/MFlowCode/MFC/archive/refs/tags/v5.1.5.tar.gz" | shasum -a 256 - name: Determine version and root URL (from checked-out formula) id: meta + shell: bash run: | set -euo pipefail FORMULA="Formula/mfc.rb" - URL="$( grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \ | tail -n 1 )" - - if [[ -z "${URL}" ]]; then - echo "Could not extract release tarball URL from ${FORMULA}" >&2 - exit 1 - fi + [[ -n "${URL}" ]] VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')" - if [[ -z "${VERSION}" ]]; then - echo "Could not parse version from URL: ${URL}" >&2 - exit 1 - fi + [[ -n "${VERSION}" ]] TAG="mfc-${VERSION}" ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" @@ -71,38 +60,18 @@ jobs: echo "Release tag: ${TAG}" echo "Bottle root_url: ${ROOT_URL}" - - name: Create temp tap with checked-out formula - run: | - set -euo pipefail - - # brew tap-new needs git identity sometimes - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - # Create a local tap and copy the formula into Homebrew's tap location - brew tap-new mflowcode/local - TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" - mkdir -p "${TAP_DIR}/Formula" - cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" - - echo "Temp tap formula:" - ls -la "${TAP_DIR}/Formula/mfc.rb" - - - name: Install formula with --build-bottle (temp tap) + - name: Install formula with --build-bottle (tap formula) + shell: bash run: | set -euo pipefail - echo "Installing mfc with --build-bottle (allowing non-fatal dylib fixup failures)..." - # Homebrew may exit non-zero due to dylib ID fixup issues in Python wheels, - # even though the formula actually installed correctly. Treat that as - # non-fatal as long as the formula is present. set +e - brew install --build-bottle mflowcode/local/mfc 2>&1 | tee /tmp/brew-install.log + brew install --build-bottle mflowcode/mfc/mfc 2>&1 | tee /tmp/brew-install.log brew_exit_code=$? set -e - if brew list mflowcode/local/mfc &>/dev/null; then + if brew list mflowcode/mfc/mfc &>/dev/null; then echo "✅ mfc installed successfully (ignoring dylib fixup warnings)" else echo "❌ mfc installation failed; propagating brew exit code" @@ -110,23 +79,22 @@ jobs: fi - name: Run Sod shock tube test case + shell: bash run: | set -euo pipefail echo "Running a simple test case (1D Sod shock tube) on ${{ matrix.os }}..." - - TESTDIR=$(mktemp -d) - cp "$(brew --prefix mflowcode/local/mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/" - + TESTDIR="$(mktemp -d)" + cp "$(brew --prefix mflowcode/mfc/mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/" cd "$TESTDIR" mfc case.py -j 1 - test -d "$TESTDIR/silo_hdf5" echo "✅ Test case ran successfully and produced output" - name: Basic installation verification + shell: bash run: | set -euo pipefail - PREFIX="$(brew --prefix mflowcode/local/mfc)" + PREFIX="$(brew --prefix mflowcode/mfc/mfc)" echo "1. Checking binaries..." test -x "${PREFIX}/bin/pre_process" @@ -149,10 +117,11 @@ jobs: echo "✅ All verification checks passed on ${{ matrix.os }}" - - name: Build bottle (temp tap formula) + - name: Build bottle (tap formula) + shell: bash run: | set -euo pipefail - brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mflowcode/local/mfc + brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mflowcode/mfc/mfc ls -1 *.bottle.* - name: Upload bottle artifacts @@ -178,25 +147,18 @@ jobs: - name: Determine version and root URL (from checked-out formula) id: meta + shell: bash run: | set -euo pipefail FORMULA="Formula/mfc.rb" - URL="$( grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' "${FORMULA}" \ | tail -n 1 )" - - if [[ -z "${URL}" ]]; then - echo "Could not extract release tarball URL from ${FORMULA}" >&2 - exit 1 - fi + [[ -n "${URL}" ]] VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')" - if [[ -z "${VERSION}" ]]; then - echo "Could not parse version from URL: ${URL}" >&2 - exit 1 - fi + [[ -n "${VERSION}" ]] TAG="mfc-${VERSION}" ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" @@ -206,6 +168,7 @@ jobs: echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" - name: Configure git for bottle merge + shell: bash run: | set -euo pipefail git config --global user.email "github-actions[bot]@users.noreply.github.com" @@ -217,22 +180,21 @@ jobs: path: bottles - name: Flatten bottle directory + shell: bash run: | set -euo pipefail echo "Before flattening:" find bottles -name '*.bottle.*' -type f - find bottles -mindepth 2 -name '*.bottle.*' -type f -exec mv {} bottles/ \; - echo "" echo "After flattening:" ls -1 bottles/*.bottle.* - name: Rename bottles for GitHub release + shell: bash run: | set -euo pipefail echo "Renaming bottles (mfc-- → mfc-)..." - for file in bottles/mfc--*.bottle.*; do if [[ -f "$file" ]]; then newname=$(echo "$file" | sed 's/mfc--/mfc-/') @@ -240,55 +202,33 @@ jobs: echo " $file → $newname" fi done - echo "" echo "Bottles ready for upload:" ls -1 bottles/*.bottle.* - - name: Ensure no conflicting taps provide mfc (merge job) - shell: bash - run: | - set -euo pipefail - brew untap mflowcode/mfc >/dev/null 2>&1 || true - brew untap mflowcode/local >/dev/null 2>&1 || true - - - name: Create temp tap for merge and copy formula into it - shell: bash - run: | - set -euo pipefail - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - brew tap-new mflowcode/local - TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" - mkdir -p "${TAP_DIR}/Formula" - cp Formula/mfc.rb "${TAP_DIR}/Formula/mfc.rb" - - brew info mflowcode/local/mfc - - name: Merge bottle metadata into formula id: merge shell: bash run: | set -euo pipefail - + shopt -s nullglob JSON_BOTTLES=(bottles/*.bottle*.json) - if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then + if (( ${#JSON_BOTTLES[@]} == 0 )); then echo "No bottle metadata (*.bottle*.json) found in bottles/" ls -la bottles/ exit 1 fi - - TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-local" - + echo "Merging bottle metadata from:" printf '%s\n' "${JSON_BOTTLES[@]}" - + brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" - - # Copy the updated formula back into this checkout so git add works here + + # brew bottle --write updates the tapped formula (setup-homebrew’s tap location). + # Copy back into the checked-out repo for committing. + TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-mfc" cp "${TAP_DIR}/Formula/mfc.rb" Formula/mfc.rb - + if git diff --quiet -- Formula/mfc.rb; then echo "bottle_updated=false" >> "$GITHUB_OUTPUT" else @@ -301,12 +241,8 @@ jobs: run: | set -euo pipefail git add Formula/mfc.rb - if git diff --cached --quiet; then - echo "No changes staged; skipping commit." - exit 0 - fi git commit -m "mfc: bottles for v${{ steps.meta.outputs.version }}" - + - name: Push bottle updates if changed if: steps.merge.outputs.bottle_updated == 'true' shell: bash From 48f4294500442f70432e02243474bce9830ab017 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 10:08:03 -0500 Subject: [PATCH 17/17] Improve bottle metadata handling in workflow Refactor bottle metadata merging and commit logic. --- .github/workflows/bottle.yml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index e5e2a87..6a23fa1 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -218,31 +218,22 @@ jobs: ls -la bottles/ exit 1 fi - + echo "Merging bottle metadata from:" printf '%s\n' "${JSON_BOTTLES[@]}" - + + BEFORE_SHA="$(git rev-parse HEAD)" brew bottle --merge --write --root-url="${{ steps.meta.outputs.root_url }}" "${JSON_BOTTLES[@]}" - - # brew bottle --write updates the tapped formula (setup-homebrew’s tap location). - # Copy back into the checked-out repo for committing. - TAP_DIR="$(brew --repository)/Library/Taps/mflowcode/homebrew-mfc" - cp "${TAP_DIR}/Formula/mfc.rb" Formula/mfc.rb - - if git diff --quiet -- Formula/mfc.rb; then - echo "bottle_updated=false" >> "$GITHUB_OUTPUT" - else + AFTER_SHA="$(git rev-parse HEAD)" + + if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then + echo "✅ brew bottle --write created commit ${AFTER_SHA}" echo "bottle_updated=true" >> "$GITHUB_OUTPUT" + else + echo "ℹ️ No commit created (bottles unchanged or already present)" + echo "bottle_updated=false" >> "$GITHUB_OUTPUT" fi - - name: Commit formula update if changed - if: steps.merge.outputs.bottle_updated == 'true' - shell: bash - run: | - set -euo pipefail - git add Formula/mfc.rb - git commit -m "mfc: bottles for v${{ steps.meta.outputs.version }}" - - name: Push bottle updates if changed if: steps.merge.outputs.bottle_updated == 'true' shell: bash