3
3
require "formula"
4
4
5
5
class Openems < Formula
6
+ include Language ::Python ::Virtualenv
7
+
6
8
desc "Electromagnetic field solver using the FDTD method"
7
9
homepage "https://www.openems.de"
8
10
@@ -19,12 +21,48 @@ class Openems < Formula
19
21
depends_on "mpfr"
20
22
depends_on "cgal"
21
23
depends_on "boost"
24
+ depends_on "python@3" => :recommended
25
+
26
+ if build . with? "python@3"
27
+ depends_on "cython"
28
+ depends_on "numpy"
29
+ depends_on "python-matplotlib"
30
+ end
22
31
23
32
def install
24
33
ENV [ "SDKROOT" ] = MacOS . sdk_path
25
34
system "cmake" , "." , *std_cmake_args
26
35
system "make"
27
36
# install is handled by ExternalProject_Add
37
+
38
+ if build . with? "python@3"
39
+ # Get python 3 sub-version we are currently using (3.x)
40
+ python_version = Formula [ "python@3" ] . version . to_s . split ( "." ) [ 0 ..1 ] . join ( "." )
41
+ python = "python#{ python_version } "
42
+
43
+ # Install non-bottled dependencies into a virtual environment
44
+ venv = virtualenv_create ( libexec , "python3" )
45
+ venv . pip_install "h5py"
46
+
47
+ # Create .pth file to reference packages in venv
48
+ ( lib /"#{ python } /site-packages/homebrew-openems-dependencies.pth" ) . write <<~EOS
49
+ #{ libexec } /lib/#{ python } /site-packages
50
+ EOS
51
+
52
+ # Use keg-only cython
53
+ ENV . prepend_path "PYTHONPATH" , "#{ Formula [ "cython" ] . libexec } /lib/#{ python } /site-packages"
54
+
55
+ # Build and install bindings
56
+ cd "CSXCAD/python" do
57
+ system Formula [ "python@3" ] . opt_bin /"python3" , "setup.py" , "build_ext" , "-I" , include , "-L" , lib , "-R" , lib , "-j" , ENV . make_jobs
58
+ system Formula [ "python@3" ] . opt_bin /"python3" , *Language ::Python . setup_install_args ( prefix )
59
+ end
60
+
61
+ cd "openEMS/python" do
62
+ system Formula [ "python@3" ] . opt_bin /"python3" , "setup.py" , "build_ext" , "-I" , include , "-L" , lib , "-R" , lib , "-j" , ENV . make_jobs
63
+ system Formula [ "python@3" ] . opt_bin /"python3" , *Language ::Python . setup_install_args ( prefix )
64
+ end
65
+ end
28
66
end
29
67
30
68
end
0 commit comments