-
Notifications
You must be signed in to change notification settings - Fork 127
homebrew: fix toolchain install without git metadata #1098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
45090f5
5b18ea1
7778507
5438ad8
8c8a522
4e09e9a
f9ce23a
d576110
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 = { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Replace the manual environment variable save/restore logic with Homebrew's |
||||||
| "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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Assigning a Pathname object to an environment variable ( Severity Level: Minor
Suggested change
Why it matters? ⭐venv is a Pathname (libexec/"venv"). Setting ENV with an explicit string (venv.to_s) is clearer and avoids any ambiguity about value types stored in ENV. In practice Pathname#to_s will be called in many contexts, but making it explicit is a small, harmless improvement that prevents subtle surprises on environments or Ruby versions that expect true String values. Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** packaging/homebrew/mfc.rb
**Line:** 81:81
**Comment:**
*Type Error: Assigning a Pathname object to an environment variable (`ENV["VIRTUAL_ENV"] = venv`) can produce a non-string value in ENV; convert the Pathname to a string to ensure the environment variable contains a proper path string.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||
|
|
||||||
| # 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 | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add the
-fflag to thecurlcommand to ensure the workflow fails on HTTP errors like 404, preventing the generation of an incorrect checksum. [possible issue, importance: 8]