Skip to content

Conversation

@yunjunz
Copy link
Member

@yunjunz yunjunz commented Jan 21, 2026

Summary by Sourcery

Update the PyPI build workflow to use macOS 15 with a Homebrew-provided gfortran and adjust macOS deployment targeting accordingly.

CI:

  • Switch GitHub Actions macOS runner from version 13 to 15 for wheel builds.
  • Install gcc via Homebrew and symlink gfortran-15 for macOS runners instead of relying on preinstalled gfortran.
  • Update macOS deployment target environment variable from 13.0 to 15.0 in the cibuildwheel configuration.

+ update macOS from 13 to 15
+ use gfortran installed from homebrew. Another option is https://github.com/numpy/numpy/pull/26812/files
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 21, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the macOS GitHub Actions build environment to macOS 15 and switches the Fortran toolchain provisioning from manually symlinked system paths to Homebrew-installed gfortran, updating the macOS deployment target accordingly while keeping the overall build-and-publish workflow intact.

Sequence diagram for the updated macOS 15 build-and-publish workflow

sequenceDiagram
    actor Developer
    participant GitHubActions as GitHub_Actions
    participant MatrixJob as build_and_publish_job
    participant RunnerMac as macos_15_runner
    participant Homebrew as Homebrew
    participant PyPI as PyPI_Registry

    Developer->>GitHubActions: push tag or release
    GitHubActions->>MatrixJob: start job with matrix os ubuntu_latest, macos_15

    GitHubActions->>RunnerMac: provision macos_15 runner
    RunnerMac->>RunnerMac: checkout code (actions_checkout)

    RunnerMac->>Homebrew: brew install gcc
    Homebrew-->>RunnerMac: gcc with gfortran_15 installed

    RunnerMac->>RunnerMac: ln -sf gfortran_15 to usr_local_bin_gfortran
    RunnerMac->>RunnerMac: gfortran --version

    RunnerMac->>RunnerMac: set CIBW_ENVIRONMENT_MACOS MACOSX_DEPLOYMENT_TARGET=15.0
    RunnerMac->>RunnerMac: run cibuildwheel build

    RunnerMac->>PyPI: upload built wheels
    PyPI-->>Developer: macOS 15 compatible wheels available
Loading

File-Level Changes

Change Details Files
Update GitHub Actions macOS runner version and deployment target to 15.
  • Change the CI job matrix to use macos-15 instead of macos-13 for wheel builds.
  • Adjust CIBW_ENVIRONMENT_MACOS to set MACOSX_DEPLOYMENT_TARGET to 15.0 instead of 13.0.
.github/workflows/build-and-publish-to-pypi.yml
Replace custom gfortran path setup on macOS with Homebrew-provided gfortran and simplify step naming.
  • Rename the macOS gfortran setup step to a more generic symlinking name.
  • Install gcc via Homebrew in the macOS job and symlink the brewed gfortran-15 into /usr/local/bin/gfortran.
  • Remove the previous manual symlinks into /usr/local/Cellar and the custom /usr/local/gfortran directory.
  • Rename the Windows Fortran setup step to use consistent "Symlink gfortran" naming without changing its implementation.
.github/workflows/build-and-publish-to-pypi.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The brew install gcc step may fail or require sudo when creating /usr/local/bin/gfortran on GitHub-hosted macOS runners (which use /opt/homebrew on ARM), so consider symlinking into $(brew --prefix)/bin or another writeable directory and updating PATH instead of writing to /usr/local.
  • Hardcoding gfortran-15 in the symlink makes the workflow brittle when Homebrew upgrades GCC; consider resolving the installed gfortran binary dynamically (e.g., via ls $(brew --prefix)/bin/gfortran-* | sort | tail -n1).
  • Raising MACOSX_DEPLOYMENT_TARGET to 15.0 will drop support for older macOS versions in your wheels; if that’s not intended, you may want to keep a lower deployment target while still building on macos-15 runners.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `brew install gcc` step may fail or require `sudo` when creating `/usr/local/bin/gfortran` on GitHub-hosted macOS runners (which use `/opt/homebrew` on ARM), so consider symlinking into `$(brew --prefix)/bin` or another writeable directory and updating PATH instead of writing to `/usr/local`.
- Hardcoding `gfortran-15` in the symlink makes the workflow brittle when Homebrew upgrades GCC; consider resolving the installed gfortran binary dynamically (e.g., via `ls $(brew --prefix)/bin/gfortran-* | sort | tail -n1`).
- Raising `MACOSX_DEPLOYMENT_TARGET` to 15.0 will drop support for older macOS versions in your wheels; if that’s not intended, you may want to keep a lower deployment target while still building on `macos-15` runners.

## Individual Comments

### Comment 1
<location> `.github/workflows/build-and-publish-to-pypi.yml:27-31` </location>
<code_context>
           fetch-depth: 0

-      - name: Provide gfortran (macOS-13)
+      - name: Symlink gfortran (macOS)
         if: runner.os == 'macOS'
         run: |
-          # https://github.com/actions/virtual-environments/issues/2524
-          # https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
-          sudo ln -s /usr/local/bin/gfortran-13 /usr/local/bin/gfortran
-          sudo mkdir /usr/local/gfortran
-          sudo ln -s /usr/local/Cellar/gcc@13/*/lib/gcc/13 /usr/local/gfortran/lib
+          brew install gcc
+          ln -sf $(brew --prefix)/bin/gfortran-15 /usr/local/bin/gfortran
           gfortran --version

</code_context>

<issue_to_address>
**issue (bug_risk):** Symlinking into /usr/local/bin without sudo on macOS runners may fail, and hardcoding gfortran-15 is brittle.

On GitHub macOS runners `/usr/local` is often not writable by the default user, so creating the symlink there without `sudo` may fail. Instead of symlinking, you could rely on `$(brew --prefix)/bin` being on `PATH`, or explicitly prepend it to `PATH` in the workflow.

Hardcoding `gfortran-15` also risks breakage when Homebrew upgrades GCC (e.g., to 16). Consider resolving the installed `gfortran-*` dynamically (e.g. via `ls $(brew --prefix)/bin/gfortran-*`) or deriving the version from a single source of truth so it doesn’t require manual updates.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

+ lower the MACOSX_DEPLOYMENT_TARGET version for better compatiability

+ use macos-latest instead of macos-15 for easier maintainence

+ grab gfortran version dynamically for easier maintainence
@yunjunz yunjunz merged commit d0abac2 into insarlab:main Jan 23, 2026
7 checks passed
@yunjunz yunjunz deleted the gh_action branch January 23, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant