@@ -73,57 +73,82 @@ def install
7373 # 2. Sets up toolchain symlink so mfc.sh can find toolchain/util.sh
7474 # 3. Ensures mfc.sh doesn't reinstall packages by copying pyproject.toml
7575 ( bin /"mfc" ) . write <<~EOS
76- #!/bin/bash
77- set -e
78-
79- # Unset VIRTUAL_ENV to ensure mfc.sh uses the copied venv, not the Cellar one
80- unset VIRTUAL_ENV
81-
82- # Create a temporary working directory (Cellar is read-only)
83- TMPDIR=$(mktemp -d)
84- trap "rm -rf $TMPDIR" EXIT
85-
86- # Copy mfc.sh to temp dir (it may try to write build artifacts)
87- cp "#{ libexec } /mfc.sh" "$TMPDIR/"
88- cd "$TMPDIR"
89-
90- # Copy toolchain directory (not symlink) so Python paths resolve correctly
91- # This prevents paths from resolving back to read-only Cellar
92- cp -R "#{ prefix } /toolchain" toolchain
93-
94- # Copy examples directory (required by mfc.sh Python code)
95- cp -R "#{ prefix } /examples" examples
96-
97- # Create build directory and copy venv (not symlink - needs to be writable)
98- # Use cp -R for a full recursive copy
99- mkdir -p build
100- cp -R "#{ venv } " build/venv
101-
102- # Copy pyproject.toml to build/ so mfc.sh thinks dependencies are already installed
103- cp "#{ prefix } /toolchain/pyproject.toml" build/pyproject.toml
104-
105- # Run mfc.sh with all arguments
106- exec ./mfc.sh "$@"
76+ #!/bin/bash
77+ set -e
78+
79+ # Unset VIRTUAL_ENV to ensure mfc.sh uses the copied venv, not the Cellar one
80+ unset VIRTUAL_ENV
81+
82+ # Create a temporary working directory (Cellar is read-only)
83+ TMPDIR=$(mktemp -d)
84+ trap "rm -rf $TMPDIR" EXIT
85+
86+ # Copy mfc.sh to temp dir (it may try to write build artifacts)
87+ cp "#{ libexec } /mfc.sh" "$TMPDIR/"
88+ cd "$TMPDIR"
89+
90+ # Copy toolchain directory (not symlink) so Python paths resolve correctly
91+ # This prevents paths from resolving back to read-only Cellar
92+ cp -R "#{ prefix } /toolchain" toolchain
93+
94+ # Patch toolchain to use Homebrew-installed binaries
95+ # Replace get_install_binpath to return Homebrew bin directory
96+ cat >> toolchain/mfc/build.py << 'PATCH_EOF'
97+
98+ # Homebrew patch: Override get_install_binpath to use pre-installed binaries
99+ _original_get_install_binpath = MFCTarget.get_install_binpath
100+ def _homebrew_get_install_binpath(self, case):
101+ return "#{ bin } /" + self.name
102+ MFCTarget.get_install_binpath = _homebrew_get_install_binpath
103+
104+ # Also override is_built to check Homebrew bin directory
105+ _original_is_built = MFCTarget.is_built
106+ def _homebrew_is_built(self, case):
107+ import os
108+ if self.name in ["pre_process", "simulation", "post_process"]:
109+ return os.path.isfile("#{ bin } /" + self.name)
110+ return _original_is_built(self, case)
111+ MFCTarget.is_built = _homebrew_is_built
112+ PATCH_EOF
113+
114+ # Copy examples directory (required by mfc.sh Python code)
115+ cp -R "#{ prefix } /examples" examples
116+
117+ # Create build directory and copy venv (not symlink - needs to be writable)
118+ # Use cp -R for a full recursive copy
119+ mkdir -p build
120+ cp -R "#{ venv } " build/venv
121+
122+ # Copy pyproject.toml to build/ so mfc.sh thinks dependencies are already installed
123+ cp "#{ prefix } /toolchain/pyproject.toml" build/pyproject.toml
124+
125+ # For 'mfc run', add --no-build flag to skip compilation
126+ if [ "$1" = "run" ]; then
127+ exec ./mfc.sh "$@" --no-build
128+ else
129+ exec ./mfc.sh "$@"
130+ fi
107131 EOS
108132 end
109133
110134 def caveats
111135 <<~EOS
112136 MFC has been installed successfully!
113137
114- Pre-built binaries are available:
138+ To run a case:
139+ mfc run <case.py>
140+
141+ Pre-built binaries are also available directly:
115142 pre_process, simulation, post_process
116143
117144 Examples are available in:
118145 #{ prefix } /examples
119146
120- Note: The 'mfc run' command requires the full MFC source tree.
121- For development workflows, clone the repository and use mfc.sh:
122- git clone https://github.com/MFlowCode/MFC.git
123- cd MFC
124- ./mfc.sh run <case.py>
147+ Example:
148+ cp #{ prefix } /examples/1D_sodshocktube/case.py .
149+ mfc run case.py
125150
126- Cantera 3.1.0 is pre-installed in the MFC virtual environment.
151+ Note: Cantera 3.1.0 is pre-installed in the MFC virtual environment.
127152 EOS
128153 end
129154
0 commit comments