From ad3200800637a3df0ca5f96a61d817d5d0dae15e Mon Sep 17 00:00:00 2001 From: Pierre Gergondet Date: Tue, 11 May 2021 20:53:37 +0800 Subject: [PATCH] sch-core-python 1.0.2 (new formula) Closes #6. Signed-off-by: Pierre Gergondet <473543+gergondet@users.noreply.github.com> --- Formula/sch-core-python.rb | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Formula/sch-core-python.rb diff --git a/Formula/sch-core-python.rb b/Formula/sch-core-python.rb new file mode 100644 index 0000000..f8234c6 --- /dev/null +++ b/Formula/sch-core-python.rb @@ -0,0 +1,39 @@ +class SchCorePython < Formula + desc "Python bindings for the sch library" + homepage "https://github.com/jrl-umi3218/sch-core-python/" + url "https://github.com/jrl-umi3218/sch-core-python/releases/download/v1.0.2/sch-core-python-v1.0.2.tar.gz" + sha256 "89e4ce4d5a479a62aba5450bf6d22540fded2e3ea7c34e177c9606104ead64f1" + license "BSD-2-Clause" + + depends_on "cmake" => :build + depends_on "cython" => :build + depends_on "sch-core" + depends_on "spacevecalg" + + def install + xy = Language::Python.major_minor_version Formula["python"].opt_bin/"python3" + ENV.prepend_create_path "PYTHONPATH", Formula["cython"].opt_libexec/"lib/python#{xy}/site-packages" + + ENV["HOMEBREW_ARCHFLAGS"] = "-march=#{Hardware.oldest_cpu}" unless build.bottle? + + inreplace "CMakeLists.txt", + "set(PIP_EXTRA_OPTIONS --target \"${PIP_TARGET}\")", + "set(PIP_EXTRA_OPTIONS --prefix \"${PIP_INSTALL_PREFIX}\")" + + args = std_cmake_args + %W[ + -DINSTALL_DOCUMENTATION:BOOL=OFF + -DPIP_INSTALL_PREFIX=#{prefix} + -DPYTHON_BINDING_FORCE_PYTHON3:BOOL=ON + ] + + system "cmake", "-S", ".", "-B", "build", *args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + end + + test do + system Formula["python"].opt_bin/"python3", "-c", <<~EOS + import sch + EOS + end +end