100 lines
3.7 KiB
Ruby
100 lines
3.7 KiB
Ruby
class Rdkit < Formula
|
|
desc "Open-source chemoinformatics library"
|
|
homepage "https://rdkit.org/"
|
|
url "https://github.com/rdkit/rdkit/archive/Release_2022_03_4.tar.gz"
|
|
sha256 "e587a7251d8c7df0139652c004bb9384c90dd335111391526643d319572f4c28"
|
|
license "BSD-3-Clause"
|
|
head "https://github.com/rdkit/rdkit.git", branch: "master"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^Release[._-](\d+(?:[._]\d+)+)$/i)
|
|
strategy :git do |tags|
|
|
tags.map { |tag| tag[regex, 1]&.gsub("_", ".") }.compact
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "d4e6875a4d9a8adfaca6df02e871aeb1d891d4d01088edb4273517312d67d85b"
|
|
sha256 cellar: :any, arm64_big_sur: "39c2ac4ee29041704f034fa651b3b75c5bfcaab7fc54cc9448cb2870a1d3af4e"
|
|
sha256 cellar: :any, monterey: "6e55f69cb29ddacf3d9b97628a93a9e6af1a0e07ba7afc26087a313b8d9686aa"
|
|
sha256 cellar: :any, big_sur: "4c4f18593d50b1a82482e7138e57aec6fd000de20ac5bae9b8073a080307d45f"
|
|
sha256 cellar: :any, catalina: "f6225fc16d559b86237cbe6088757b14dd7ea233952013ecdf08c0a5121f2c6e"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "d278cc193c4fd2ef3c4a0f15df35ee0e93f2734931577439dcd1d8996a47e895"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "swig" => :build
|
|
depends_on "boost"
|
|
depends_on "boost-python3"
|
|
depends_on "eigen"
|
|
depends_on "freetype"
|
|
depends_on "numpy"
|
|
depends_on "postgresql"
|
|
depends_on "py3cairo"
|
|
depends_on "python@3.9"
|
|
|
|
def install
|
|
ENV.cxx11
|
|
ENV.libcxx
|
|
ENV.append "CFLAGS", "-Wno-parentheses -Wno-logical-op-parentheses -Wno-format"
|
|
ENV.append "CXXFLAGS", "-Wno-parentheses -Wno-logical-op-parentheses -Wno-format"
|
|
|
|
# Get Python location
|
|
python_executable = Formula["python@3.9"].opt_bin/"python3"
|
|
py3ver = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
|
|
py3prefix = if OS.mac?
|
|
Formula["python@3.9"].opt_frameworks/"Python.framework/Versions/#{py3ver}"
|
|
else
|
|
Formula["python@3.9"].opt_prefix
|
|
end
|
|
py3include = "#{py3prefix}/include/python#{py3ver}"
|
|
numpy_include = Formula["numpy"].opt_lib/"python#{py3ver}/site-packages/numpy/core/include"
|
|
|
|
# set -DMAEPARSER and COORDGEN_FORCE_BUILD=ON to avoid conflicts with some formulae i.e. open-babel
|
|
args = std_cmake_args + %W[
|
|
-DCMAKE_INSTALL_RPATH=#{opt_lib}
|
|
-DRDK_INSTALL_INTREE=OFF
|
|
-DRDK_BUILD_SWIG_WRAPPERS=OFF
|
|
-DRDK_BUILD_AVALON_SUPPORT=ON
|
|
-DRDK_BUILD_PGSQL=ON
|
|
-DRDK_PGSQL_STATIC=ON
|
|
-DMAEPARSER_FORCE_BUILD=ON
|
|
-DCOORDGEN_FORCE_BUILD=ON
|
|
-DRDK_BUILD_INCHI_SUPPORT=ON
|
|
-DRDK_BUILD_CPP_TESTS=OFF
|
|
-DRDK_INSTALL_STATIC_LIBS=OFF
|
|
-DRDK_BUILD_CAIRO_SUPPORT=ON
|
|
-DRDK_BUILD_YAEHMOP_SUPPORT=ON
|
|
-DRDK_BUILD_FREESASA_SUPPORT=ON
|
|
-DBoost_NO_BOOST_CMAKE=ON
|
|
-DPYTHON_INCLUDE_DIR=#{py3include}
|
|
-DPYTHON_EXECUTABLE=#{python_executable}
|
|
-DPYTHON_NUMPY_INCLUDE_PATH=#{numpy_include}
|
|
]
|
|
|
|
system "cmake", ".", *args
|
|
system "make"
|
|
system "make", "install"
|
|
|
|
site_packages = "lib/python#{py3ver}/site-packages"
|
|
(prefix/site_packages/"homebrew-rdkit.pth").write libexec/site_packages
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
You may need to add RDBASE to your environment variables.
|
|
For Bash, put something like this in your $HOME/.bashrc:
|
|
export RDBASE=#{HOMEBREW_PREFIX}/share/RDKit
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
system Formula["python@3.9"].opt_bin/"python3", "-c", "import rdkit"
|
|
(testpath/"test.py").write <<~EOS
|
|
from rdkit import Chem ; print(Chem.MolToSmiles(Chem.MolFromSmiles('C1=CC=CN=C1')))
|
|
EOS
|
|
assert_match "c1ccncc1", shell_output("#{Formula["python@3.9"].opt_bin}/python3 test.py 2>&1")
|
|
end
|
|
end
|