-
Notifications
You must be signed in to change notification settings - Fork 79
/
openEMS.rb
75 lines (59 loc) · 2.37 KB
/
openEMS.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Homebrew formula for installing on macOS
require "formula"
class Openems < Formula
include Language::Python::Virtualenv
desc "Electromagnetic field solver using the FDTD method"
homepage "https://www.openems.de"
head "https://github.com/thliebig/openEMS-Project.git", branch: "master"
depends_on "cmake" => :build
depends_on "qt@6"
depends_on "vtk"
depends_on "tinyxml"
depends_on "hdf5"
depends_on "gmp"
depends_on "mpfr"
depends_on "cgal"
depends_on "boost"
depends_on "python@3" => :recommended
if build.with? "python@3"
depends_on "cython"
depends_on "numpy"
depends_on "python-matplotlib"
depends_on "python-setuptools"
end
def install
# Workaround for CMake HDF5 bug: https://gitlab.kitware.com/cmake/cmake/-/issues/25358
%w[openEMS/CMakeLists.txt CSXCAD/CMakeLists.txt AppCSXCAD/CMakeLists.txt].each do |file|
inreplace file do |s|
s.gsub! "find_package(HDF5 1.8 ", "find_package(HDF5 "
end
end
ENV["SDKROOT"] = MacOS.sdk_path
system "cmake", ".", *std_cmake_args
system "make"
# install is handled by ExternalProject_Add
if build.with? "python@3"
# Get python 3 sub-version we are currently using (3.x)
python_version = Formula["python@3"].version.to_s.split(".")[0..1].join(".")
python = "python#{python_version}"
# Install non-bottled dependencies into a virtual environment
venv = virtualenv_create(libexec, "python3")
venv.pip_install "h5py"
# Create .pth file to reference packages in venv
(lib/"#{python}/site-packages/homebrew-openems-dependencies.pth").write <<~EOS
#{libexec}/lib/#{python}/site-packages
EOS
# Use keg-only cython
ENV.prepend_path "PYTHONPATH", "#{Formula["cython"].libexec}/lib/#{python}/site-packages"
# Build and install bindings
cd "CSXCAD/python" do
system Formula["python@3"].opt_bin/"python3", "setup.py", "build_ext", "-I", include, "-L", lib, "-R", lib, "-j", ENV.make_jobs
system Formula["python@3"].opt_bin/"python3", *Language::Python.setup_install_args(prefix)
end
cd "openEMS/python" do
system Formula["python@3"].opt_bin/"python3", "setup.py", "build_ext", "-I", include, "-L", lib, "-R", lib, "-j", ENV.make_jobs
system Formula["python@3"].opt_bin/"python3", *Language::Python.setup_install_args(prefix)
end
end
end
end