From 45090f5f609488332c9943ab4b6853b4763558a0 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 19 Dec 2025 08:53:28 -0500 Subject: [PATCH 1/7] homebrew: fix toolchain install without git metadata --- packaging/homebrew/mfc.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packaging/homebrew/mfc.rb b/packaging/homebrew/mfc.rb index 7bacf97376..ff330df974 100644 --- a/packaging/homebrew/mfc.rb +++ b/packaging/homebrew/mfc.rb @@ -29,12 +29,19 @@ 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" + system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel", "setuptools-scm" # 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 system venv/"bin/pip", "install", "cantera==3.1.0" + # MFC's toolchain uses VCS-derived versioning (via Hatch/hatch-vcs) and Homebrew builds from + # GitHub release tarballs without a .git directory. Provide a fallback/pretend version so + # metadata generation succeeds during pip install. + ENV["SETUPTOOLS_SCM_PRETEND_VERSION"] = version.to_s + ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC"] = version.to_s + ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc"] = version.to_s + # Install MFC Python package and dependencies into venv # Use editable install (-e) to avoid RECORD file issues when venv is symlinked at runtime # Dependencies will use pre-built wheels from PyPI From 5b18ea180480b5ed1617e3ab2b569b7301dfc8d7 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 19 Dec 2025 09:00:12 -0500 Subject: [PATCH 2/7] homebrew: scope pretend-version vars + update cantera to >=3.1.0 --- packaging/homebrew/mfc.rb | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/packaging/homebrew/mfc.rb b/packaging/homebrew/mfc.rb index ff330df974..7f71f1b957 100644 --- a/packaging/homebrew/mfc.rb +++ b/packaging/homebrew/mfc.rb @@ -33,20 +33,38 @@ def install # 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 - system venv/"bin/pip", "install", "cantera==3.1.0" - - # MFC's toolchain uses VCS-derived versioning (via Hatch/hatch-vcs) and Homebrew builds from - # GitHub release tarballs without a .git directory. Provide a fallback/pretend version so - # metadata generation succeeds during pip install. - ENV["SETUPTOOLS_SCM_PRETEND_VERSION"] = version.to_s - ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC"] = version.to_s - ENV["SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc"] = version.to_s + # Match the version constraint from toolchain/pyproject.toml + system venv/"bin/pip", "install", "--only-binary=:all:", "cantera>=3.1.0" # Install MFC Python package and dependencies into venv # Use editable install (-e) to avoid RECORD file issues when venv is symlinked at runtime # Dependencies will use pre-built wheels from PyPI # Keep toolchain in buildpath for now - mfc.sh needs it there - system venv/"bin/pip", "install", "-e", buildpath/"toolchain" + # + # 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. + pretend_env = { + "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version.to_s, + "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version.to_s, + } + saved_env = {} + pretend_env.each do |k, v| + saved_env[k] = ENV[k] + ENV[k] = v + end + + begin + system venv/"bin/pip", "install", "-e", buildpath/"toolchain" + ensure + pretend_env.each_key do |k| + if saved_env[k].nil? + ENV.delete(k) + else + ENV[k] = saved_env[k] + end + end + end # Create symlink so mfc.sh uses our pre-installed venv mkdir_p "build" From 777850783a6f93ae5e37e39888d71224167ca878 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 19 Dec 2025 09:01:41 -0500 Subject: [PATCH 3/7] homebrew: add SETUPTOOLS_SCM_PRETEND_VERSION fallback for hatch-vcs --- packaging/homebrew/mfc.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/homebrew/mfc.rb b/packaging/homebrew/mfc.rb index 7f71f1b957..684065df35 100644 --- a/packaging/homebrew/mfc.rb +++ b/packaging/homebrew/mfc.rb @@ -47,6 +47,7 @@ def install pretend_env = { "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version.to_s, "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version.to_s, + "SETUPTOOLS_SCM_PRETEND_VERSION" => version.to_s, # Fallback for hatch-vcs/setuptools-scm } saved_env = {} pretend_env.each do |k, v| From 5438ad8bf0ac26b7a0aa04b866e6ff53ce13ebad Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 19 Dec 2025 09:03:40 -0500 Subject: [PATCH 4/7] homebrew: fix rubocop style warning (use ENV.fetch) --- packaging/homebrew/mfc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/homebrew/mfc.rb b/packaging/homebrew/mfc.rb index 684065df35..c36a70c905 100644 --- a/packaging/homebrew/mfc.rb +++ b/packaging/homebrew/mfc.rb @@ -51,7 +51,7 @@ def install } saved_env = {} pretend_env.each do |k, v| - saved_env[k] = ENV[k] + saved_env[k] = ENV.fetch(k, nil) ENV[k] = v end From 8c8a52229a6b0df668ff40823d553dbaf31a6751 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 19 Dec 2025 09:06:18 -0500 Subject: [PATCH 5/7] homebrew: fix hash alignment for rubocop --- packaging/homebrew/mfc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/homebrew/mfc.rb b/packaging/homebrew/mfc.rb index c36a70c905..2e7d0a02f1 100644 --- a/packaging/homebrew/mfc.rb +++ b/packaging/homebrew/mfc.rb @@ -47,7 +47,7 @@ def install pretend_env = { "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MFC" => version.to_s, "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_mfc" => version.to_s, - "SETUPTOOLS_SCM_PRETEND_VERSION" => version.to_s, # Fallback for hatch-vcs/setuptools-scm + "SETUPTOOLS_SCM_PRETEND_VERSION" => version.to_s, # Fallback for hatch-vcs/setuptools-scm } saved_env = {} pretend_env.each do |k, v| From 4e09e9a409e666a7c16fc318544765fa77d98db9 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 01:23:35 -0500 Subject: [PATCH 6/7] fix homebrew junk --- packaging/homebrew/mfc.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packaging/homebrew/mfc.rb b/packaging/homebrew/mfc.rb index 2e7d0a02f1..e4e50da94b 100644 --- a/packaging/homebrew/mfc.rb +++ b/packaging/homebrew/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" @@ -29,7 +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" + 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 @@ -42,8 +46,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 +61,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? @@ -75,6 +80,11 @@ def install # 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 f9ce23ae144ca32154f8b0f0de9e4bfc4d6b93be Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 20 Dec 2025 10:32:41 -0500 Subject: [PATCH 7/7] last fixes i hope --- .github/workflows/deploy-tap.yml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-tap.yml b/.github/workflows/deploy-tap.yml index 769cce98aa..5e4a56d87e 100644 --- a/.github/workflows/deploy-tap.yml +++ b/.github/workflows/deploy-tap.yml @@ -7,15 +7,14 @@ on: paths: - 'packaging/homebrew/mfc.rb' - 'packaging/homebrew/README.md' - # Deploy to tap on push to master + # Deploy to tap on push to master (only when formula files changed) push: - branches: [ master, homebrew-new ] + branches: [ master ] paths: - 'packaging/homebrew/mfc.rb' - 'packaging/homebrew/README.md' - tags: - - 'v*.*.*' - # Allow manual trigger for testing + # Deploy to tap when a tag is created (no paths filter on tag creation) + create: workflow_dispatch: permissions: @@ -25,6 +24,7 @@ jobs: deploy-tap: name: Audit and deploy formula runs-on: macos-14 + if: github.event_name != 'create' || github.event.ref_type == 'tag' permissions: contents: write pull-requests: write @@ -37,28 +37,38 @@ jobs: - name: Determine event metadata id: meta run: | - if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then - VERSION="${GITHUB_REF_NAME#v}" + set -euo pipefail + EVENT_NAME="${{ github.event_name }}" + REF_NAME="${{ github.ref_name }}" + + if [[ "${EVENT_NAME}" == "create" ]]; then + # Tag creation event + VERSION="${REF_NAME#v}" + URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${VERSION}.tar.gz" + elif [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then + # Tag push event + VERSION="${REF_NAME#v}" URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${VERSION}.tar.gz" else # Extract URL from current formula to re-audit and sync - URL="$(grep -Eo 'https://github.com/.*/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' packaging/homebrew/mfc.rb | head -n1)" + URL="$(grep -Eo 'https://github.com/[^"]+/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' packaging/homebrew/mfc.rb | tail -n 1)" VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')" fi + SHASUM="$(curl -sL "${URL}" | shasum -a 256 | awk '{print $1}')" echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "url=${URL}" >> $GITHUB_OUTPUT echo "sha256=${SHASUM}" >> $GITHUB_OUTPUT - echo "Event: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY + echo "Event: ${EVENT_NAME}" >> $GITHUB_STEP_SUMMARY echo "Version: ${VERSION}" >> $GITHUB_STEP_SUMMARY - if [[ "${{ github.event_name }}" == "pull_request" ]]; then + if [[ "${EVENT_NAME}" == "pull_request" ]]; then echo "Mode: Audit only (PR)" >> $GITHUB_STEP_SUMMARY else echo "Mode: Audit and deploy" >> $GITHUB_STEP_SUMMARY fi - name: Update formula (for tag events) - if: github.ref_type == 'tag' + if: github.event_name == 'create' || github.ref_type == 'tag' run: | /usr/bin/sed -i '' "s@^ url \".*\"@ url \"${{ steps.meta.outputs.url }}\"@" packaging/homebrew/mfc.rb /usr/bin/sed -i '' "s@^ sha256 \".*\"@ sha256 \"${{ steps.meta.outputs.sha256 }}\"@" packaging/homebrew/mfc.rb