Skip to content

Commit 487b88f

Browse files
committed
Fix: Build Cantera before MFC to avoid PyPI dependency error
The issue was that ./mfc.sh build was running first and trying to create its own venv with cantera==3.1.0 from PyPI (which doesn't exist). Solution: 1. Create venv with [email protected] FIRST 2. Build and install Cantera 3.1.0 from source into venv 3. Install MFC Python toolchain into venv (with Cantera already there) 4. Symlink build/venv to our pre-installed venv 5. Set VIRTUAL_ENV and PATH environment variables 6. Run mfc.sh build (which now uses existing venv with Cantera) This ensures mfc.sh uses our pre-configured venv instead of creating a new one and trying to install the non-existent cantera==3.1.0 from PyPI.
1 parent c0168b7 commit 487b88f

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

packaging/homebrew/mfc.rb

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,12 @@ class Mfc < Formula
2929
end
3030

3131
def install
32-
# MFC uses a Python wrapper script for building
33-
# Homebrew's superenv handles compiler setup via gcc dependency
34-
system "./mfc.sh", "build",
35-
"-t", "pre_process", "simulation", "post_process",
36-
"-j", ENV.make_jobs
37-
38-
# Install binaries
39-
# MFC installs each binary to a separate hashed subdirectory, find them individually
40-
%w[pre_process simulation post_process].each do |binary|
41-
binary_paths = Dir.glob("build/install/*/bin/#{binary}")
42-
raise "Could not find #{binary}" if binary_paths.empty?
43-
44-
bin.install binary_paths.first
45-
end
46-
47-
# Install mfc.sh script to libexec
48-
libexec.install "mfc.sh"
49-
50-
# Install Python toolchain
51-
# The entire toolchain directory is required for mfc.sh functionality
52-
prefix.install "toolchain"
53-
54-
# Install examples
55-
pkgshare.install "examples"
56-
57-
# Create Python virtual environment first
32+
# Create Python virtual environment first (before MFC build)
5833
venv = libexec/"venv"
5934
system Formula["[email protected]"].opt_bin/"python3.12", "-m", "venv", venv
6035
system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel"
6136

62-
# Build and install Cantera 3.1.0 from source
37+
# Build and install Cantera 3.1.0 from source BEFORE MFC build
6338
resource("cantera").stage do
6439
# Install Cantera build dependencies
6540
system venv/"bin/pip", "install", "cython", "numpy", "ruamel.yaml"
@@ -86,9 +61,40 @@ def install
8661
end
8762
end
8863

89-
# Install MFC Python package and remaining dependencies into venv
64+
# Install Python toolchain (needed before build)
65+
prefix.install "toolchain"
66+
67+
# Install MFC Python package and dependencies into venv
9068
system venv/"bin/pip", "install", "-e", prefix/"toolchain"
9169

70+
# Create symlink so mfc.sh uses our pre-installed venv
71+
mkdir_p "build"
72+
ln_sf venv, "build/venv"
73+
74+
# Now build MFC with pre-configured venv
75+
# Set VIRTUAL_ENV so mfc.sh uses existing venv instead of creating new one
76+
ENV["VIRTUAL_ENV"] = venv
77+
ENV["PATH"] = "#{venv}/bin:#{ENV["PATH"]}"
78+
79+
system "./mfc.sh", "build",
80+
"-t", "pre_process", "simulation", "post_process",
81+
"-j", ENV.make_jobs
82+
83+
# Install binaries
84+
# MFC installs each binary to a separate hashed subdirectory, find them individually
85+
%w[pre_process simulation post_process].each do |binary|
86+
binary_paths = Dir.glob("build/install/*/bin/#{binary}")
87+
raise "Could not find #{binary}" if binary_paths.empty?
88+
89+
bin.install binary_paths.first
90+
end
91+
92+
# Install mfc.sh script to libexec
93+
libexec.install "mfc.sh"
94+
95+
# Install examples
96+
pkgshare.install "examples"
97+
9298
# Create a wrapper that sets up a working environment for mfc.sh
9399
# The wrapper uses a temporary directory since Cellar is read-only and
94100
# activates the pre-installed Python virtual environment

0 commit comments

Comments
 (0)