@@ -72,28 +72,31 @@ def install
7272 # 1. Works around read-only Cellar issue by copying venv to tmpdir
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
75- ( bin /"mfc" ) . write <<~EOS
76- #!/bin/bash
77- set -e
7875
79- # Unset VIRTUAL_ENV to ensure mfc.sh uses the copied venv, not the Cellar one
80- unset VIRTUAL_ENV
76+ # Create wrapper script in buildpath first, then install it
77+ wrapper_script = buildpath /"mfc_wrapper"
78+ wrapper_script . write <<~EOS
79+ #!/bin/bash
80+ set -e
8181
82- # Create a temporary working directory (Cellar is read-only)
83- TMPDIR=$(mktemp -d)
84- trap "rm -rf $TMPDIR" EXIT
82+ # Unset VIRTUAL_ENV to ensure mfc.sh uses the copied venv, not the Cellar one
83+ unset VIRTUAL_ENV
8584
86- # Copy mfc.sh to temp dir (it may try to write build artifacts )
87- cp " #{ libexec } /mfc.sh" "$ TMPDIR/"
88- cd " $TMPDIR"
85+ # Create a temporary working directory (Cellar is read-only )
86+ TMPDIR=$(mktemp -d)
87+ trap "rm -rf $TMPDIR" EXIT
8988
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
89+ # Copy mfc.sh to temp dir (it may try to write build artifacts)
90+ cp " #{ libexec } /mfc.sh" "$TMPDIR/"
91+ cd "$TMPDIR"
9392
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'
93+ # Copy toolchain directory (not symlink) so Python paths resolve correctly
94+ # This prevents paths from resolving back to read-only Cellar
95+ cp -R "#{ prefix } /toolchain" toolchain
96+
97+ # Patch toolchain to use Homebrew-installed binaries
98+ # Replace get_install_binpath to return Homebrew bin directory
99+ cat >> toolchain/mfc/build.py << 'PATCH_EOF'
97100
98101 # Homebrew patch: Override get_install_binpath to use pre-installed binaries
99102 _original_get_install_binpath = MFCTarget.get_install_binpath
@@ -108,29 +111,30 @@ def _homebrew_is_buildable(self):
108111 return False # Skip building - use pre-installed binaries
109112 return _original_is_buildable(self)
110113 MFCTarget.is_buildable = _homebrew_is_buildable
111- PATCH_EOF
114+ PATCH_EOF
112115
113- # Copy examples directory (required by mfc.sh Python code)
114- cp -R "#{ prefix } /examples" examples
116+ # Copy examples directory (required by mfc.sh Python code)
117+ cp -R "#{ prefix } /examples" examples
115118
116- # Create build directory and copy venv (not symlink - needs to be writable)
117- # Use cp -R for a full recursive copy
118- mkdir -p build
119- cp -R "#{ venv } " build/venv
119+ # Create build directory and copy venv (not symlink - needs to be writable)
120+ # Use cp -R for a full recursive copy
121+ mkdir -p build
122+ cp -R "#{ venv } " build/venv
120123
121- # Copy pyproject.toml to build/ so mfc.sh thinks dependencies are already installed
122- cp "#{ prefix } /toolchain/pyproject.toml" build/pyproject.toml
124+ # Copy pyproject.toml to build/ so mfc.sh thinks dependencies are already installed
125+ cp "#{ prefix } /toolchain/pyproject.toml" build/pyproject.toml
123126
124- # For 'mfc run', add --no-build flag to skip compilation
125- if [ "$1" = "run" ]; then
126- exec ./mfc.sh "$@" --no-build
127- else
128- exec ./mfc.sh "$@"
129- fi
127+ # For 'mfc run', add --no-build flag to skip compilation
128+ if [ "$1" = "run" ]; then
129+ exec ./mfc.sh "$@" --no-build
130+ else
131+ exec ./mfc.sh "$@"
132+ fi
130133 EOS
131134
132- # Make the wrapper script executable
133- ( bin /"mfc" ) . chmod 0755
135+ # Make wrapper executable and install it
136+ wrapper_script . chmod 0755
137+ install wrapper_script , bin /"mfc"
134138 end
135139
136140 def caveats
0 commit comments