Skip to content
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

#medfile fix Python.h error #478

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 32 additions & 26 deletions Formula/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,65 @@ class MedFileAT411 < Formula
sha256 cellar: :any, mojave: "ccdbcb2c39a985b2a4538fc96e39354312635b84f50761c5ebbf1f2206d02faf"
end

# TODO: a valid regex is required for livecheck
# livecheck do
# url :stable
# # url "https://files.salome-platform.org/Salome/other/"
# # regex(/^v?(\d+(?:\.\d+)+)$/i)
# # regex(/^med-4.\d.\d.tar.gz$/i)
# end

depends_on "cmake" => :build
depends_on "freecad/freecad/[email protected]" => :build
depends_on "[email protected]" => :build
depends_on "gcc"
depends_on "hdf5"
depends_on "libaec"

patch do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/8efd96c520e35c36cbd55460669a643b53b27c29/patches/med-file-4.1.1-cmake-find-python-h.patch"
sha256 "8fe32c1217704c5c963f35adbf1a05f3e7e3f1b3db686066c5bdd34bf45e409a"
end

patch do
url "https://gitweb.gentoo.org/repo/gentoo.git/plain/sci-libs/med/files/med-4.1.0-0003-build-against-hdf5-1.14.patch"
sha256 "d4551df69f4dcb3c8a649cdeb0a6c9d27a03aebc0c6dcdba74cac39a8732f8d1"
end

# def pythons
# deps.map(&:to_formula)
# .select { |f| f.name.match?(/^python@3\.\d+$/) }
# TODO: a valid regex is required for livecheck
# livecheck do
# url :stable
# # url "https://files.salome-platform.org/Salome/other/"
# # regex(/^v?(\d+(?:\.\d+)+)$/i)
# # regex(/^med-4.\d.\d.tar.gz$/i)
# end

def pythons
deps.map(&:to_formula)
.select { |f| f.name.match?(/^python@\d\.\d+$/) }
.map { |f| f.opt_libexec/"bin/python" }
end

def python3
"python3.11"
end

def install
# ENV.cxx11
hbp = HOMEBREW_PREFIX

# hb default values not used
rm_std_cmake_args = [
"-DBUILD_TESTING=OFF",
"-DCMAKE_INSTALL_LIBDIR",
]

args = std_cmake_args + %W[
-DHOMEBREW_PREFIX=#{hbp}
-DMEDFILE_BUILD_PYTHON=ON
-DMEDFILE_BUILD_TESTS=OFF
-DMEDFILE_INSTALL_DOC=OFF
-DPYTHON_EXECUTABLE=#{which(python3)}"
-DCMAKE_PREFIX_PATH=#{Formula["hdf5"].opt_lib};#{Formula["gcc"].opt_lib};
-DPYTHON_EXECUTABLE=#{Formula["[email protected]"].opt_bin}/python3.11
-DCMAKE_PREFIX_PATH=#{Formula["hdf5"].opt_prefix};#{Formula["gcc"].opt_prefix};
-DCMAKE_INSTALL_RPATH=#{rpath}
]

args << if OS.mac?
"-DPYTHON_LIBRARY=#{hbp}/opt/[email protected]/Frameworks/Python.framework/Versions/Current/lib/libpython3.11.dylib"
if OS.mac?
args << "-DPYTHON_LIBRARY=#{hbp}/opt/[email protected]/Frameworks/Python.framework/Versions/Current/lib" \
"/libpython3.11.dylib"
args << "-DPYTHON_INCLUDE_DIRS=#{Formula["[email protected]"].opt_prefix}/Frameworks/Python.framework/Versions/" \
"3.11/Headers"
else
"-DPYTHON_LIBRARY=#{hbp}/opt/[email protected]/lib/libpython3.11.so"
# NOTE: specifying the below cmake var still did not help in finding `Python.h`
args << "-DPYTHON_INCLUDE_DIRS=#{hbp}/opt/[email protected]/include/python3.11"
args << "-DPYTHON_LIBRARY=#{hbp}/opt/[email protected]/lib/libpython3.11.so"
end

# Remove unwanted values from args
args.reject! { |arg| rm_std_cmake_args.any? { |value| arg.include?(value) } }

mkdir "build" do
system "cmake", "..", *args
system "make"
Expand Down
Loading