Skip to content

Commit

Permalink
med-file update formula for gnu+linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatch committed May 3, 2024
1 parent 92fc9b3 commit 241c9b5
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions Formula/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,49 @@ def install
"-DCMAKE_INSTALL_LIBDIR",
]

# Get the Python includes directory without duplicates
ENV["PYTHON"] = Formula["[email protected]"].opt_bin/"python3.11"

py_inc_output = `python3.11-config --includes`
py_inc_dirs = py_inc_output.scan(/-I([^\s]+)/).flatten.uniq
py_inc_dir = py_inc_dirs.join(" ")

py_lib_path = if OS.mac?
`python3.11-config --configdir`.strip + "/libpython3.11.dylib"
else
`python3.11-config --configdir`.strip + "/libpython3.11.a"
end

puts "--------------------------------------------"
puts "PYTHON=#{ENV["PYTHON"]}"
puts "PYTHON_INCLUDE_DIR=#{py_inc_dir}"
puts "PYTHON_LIBRARY=#{py_lib_path}"

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

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"
args << "-DPYTHON_LIBRARY=#{py_lib_path}"
args << "-DPYTHON_INCLUDE_DIRS=#{py_inc_dir}"
else
# 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"
args << "-DPYTHON_INCLUDE_DIRS=#{py_inc_dir}"
args << "-DPYTHON_LIBRARY=#{py_lib_path}"
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"
system "make", "install"
end
system "cmake", "-S", ".", "-B", "build", *args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
Expand Down

0 comments on commit 241c9b5

Please sign in to comment.