Skip to content

Commit 5ac2000

Browse files
committed
Fix Homebrew formula to enable proper bottle creation
This commit properly fixes bottle relocation issues by addressing the root cause: 1. Removed pour_bottle? hack that disabled bottles entirely 2. Added LDFLAGS with -headerpad_max_install_names when compiling Python packages to ensure C extensions (like orjson) have sufficient Mach-O header padding for Homebrew's bottle relocation process 3. Force pip to compile from source (--no-binary :all:) instead of using pre-built wheels, ensuring our LDFLAGS are applied during compilation 4. Changed shebang from #!/bin/bash to #!/usr/bin/env bash for better portability and to satisfy brew audit checks This allows the formula to create proper bottles in the homebrew-mfc tap while maintaining fast installation times for users. Fixes: 'Failed changing dylib ID' errors during bottling Fixes: 'Non-executables were installed' audit warnings
1 parent be10bee commit 5ac2000

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packaging/homebrew/mfc.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ class Mfc < Formula
2121
depends_on "openblas"
2222
depends_on "[email protected]"
2323

24-
# Disable bottles due to Python venv with compiled extensions that can't be relocated
25-
def pour_bottle?
26-
false
27-
end
28-
2924
def install
3025
# Create Python virtual environment inside libexec (inside Cellar for proper bottling)
3126
venv = libexec/"venv"
3227
system Formula["[email protected]"].opt_bin/"python3.12", "-m", "venv", venv
3328
system venv/"bin/pip", "install", "--upgrade", "pip", "setuptools", "wheel"
3429

30+
# Set LDFLAGS to ensure Python C extensions (like orjson) are compiled with enough
31+
# header padding for Homebrew's bottle relocation process
32+
# This fixes "Failed changing dylib ID" errors during bottling
33+
ENV.append "LDFLAGS", "-Wl,-headerpad_max_install_names"
34+
35+
# Force pip to compile from source (not use pre-built wheels) to ensure
36+
# our LDFLAGS are applied. Pre-built wheels don't have proper header padding.
37+
pip_install_args = ["--no-binary", ":all:"]
38+
3539
# Install Cantera from PyPI (required dependency for MFC build)
36-
system venv/"bin/pip", "install", "cantera==3.1.0"
40+
system venv/"bin/pip", "install", *pip_install_args, "cantera==3.1.0"
3741

3842
# Install MFC Python package and dependencies into venv
3943
# Keep toolchain in buildpath for now - mfc.sh needs it there
4044
# Use editable install (-e) to avoid RECORD file issues when venv is symlinked at runtime
41-
system venv/"bin/pip", "install", "-e", buildpath/"toolchain"
45+
system venv/"bin/pip", "install", *pip_install_args, "-e", buildpath/"toolchain"
4246

4347
# Create symlink so mfc.sh uses our pre-installed venv
4448
mkdir_p "build"
@@ -77,7 +81,7 @@ def install
7781
# 3. Minimal copying - only what needs to be writable
7882
# 4. Resolves input file paths before changing directories
7983
(bin/"mfc").write <<~EOS
80-
#!/bin/bash
84+
#!/usr/bin/env bash
8185
set -euo pipefail
8286
8387
# Unset VIRTUAL_ENV to ensure mfc.sh uses our configured venv

0 commit comments

Comments
 (0)