homebrew-core/Formula/graph-tool.rb

147 lines
5.6 KiB
Ruby

class GraphTool < Formula
include Language::Python::Virtualenv
desc "Efficient network analysis for Python 3"
homepage "https://graph-tool.skewed.de/"
url "https://downloads.skewed.de/graph-tool/graph-tool-2.45.tar.bz2"
sha256 "f92da7accfda02b29791efe4f0b3ed93329f27232af4d3afc07c92421ec68668"
license "LGPL-3.0-or-later"
revision 4
livecheck do
url "https://downloads.skewed.de/graph-tool/"
regex(/href=.*?graph-tool[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
rebuild 1
sha256 arm64_ventura: "5bb817fb8e5a6f0982455d302b45fdd478196e1e2de5c61ca30174a280b1cf2e"
sha256 arm64_monterey: "09e64532a9ea056866d595475b08d407d1077c61411983f1d79568ac85c69ac1"
sha256 arm64_big_sur: "f5fee6072f77684bc62cbb6736c80890d183f12e91fc65530c0f7e4e8f180301"
sha256 ventura: "139a22dfd0b331cba322980fbfc6e8838c9e51f5d6ca57b5f0f3d494b3a5d47a"
sha256 monterey: "5dade6b3df0ac3d6774f480ad5e2e0d96ab90000160503acfb58f387b4fd381a"
sha256 big_sur: "98caed03113decd462ac679a2e3d85fe970318104db44ababac863fad385ac97"
sha256 cellar: :any_skip_relocation, x86_64_linux: "7b80f6ec2ef398da9a4d21e553328d95b0cc01a5bd0c9ce33b130467b6a801f4"
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "boost"
depends_on "boost-python3"
depends_on "cairomm@1.14"
depends_on "cgal"
depends_on "fonttools"
depends_on "google-sparsehash"
depends_on "gtk+3"
depends_on "librsvg"
depends_on macos: :mojave # for C++17
depends_on "numpy"
depends_on "pillow"
depends_on "py3cairo"
depends_on "pygobject3"
depends_on "python@3.11"
depends_on "scipy"
depends_on "six"
uses_from_macos "expat" => :build
# https://git.skewed.de/count0/graph-tool/-/wikis/Installation-instructions#manual-compilation
fails_with :gcc do
version "6"
cause "Requires C++17 compiler"
end
# Resources are for Python `matplotlib` and `zstandard` packages
resource "contourpy" do
url "https://files.pythonhosted.org/packages/8f/4f/8a5789867f2a928fd9b32e7e8d4bc0f27a765aa7056989e7427f2c2a1966/contourpy-1.0.6.tar.gz"
sha256 "6e459ebb8bb5ee4c22c19cc000174f8059981971a33ce11e17dddf6aca97a142"
end
resource "cycler" do
url "https://files.pythonhosted.org/packages/34/45/a7caaacbfc2fa60bee42effc4bcc7d7c6dbe9c349500e04f65a861c15eb9/cycler-0.11.0.tar.gz"
sha256 "9c87405839a19696e837b3b818fed3f5f69f16f1eec1a1ad77e043dcea9c772f"
end
resource "kiwisolver" do
url "https://files.pythonhosted.org/packages/5f/5c/272a7dd49a1914f35cd8d6d9f386defa8b047f6fbd06badd6b77b3ba24e7/kiwisolver-1.4.4.tar.gz"
sha256 "d41997519fcba4a1e46eb4a2fe31bc12f0ff957b2b81bac28db24744f333e955"
end
resource "matplotlib" do
url "https://files.pythonhosted.org/packages/91/1c/a48fd779287df3425c289cc2ff728980a5b355f15f4c3c40e1822770ba44/matplotlib-3.6.2.tar.gz"
sha256 "b03fd10a1709d0101c054883b550f7c4c5e974f751e2680318759af005964990"
end
resource "packaging" do
url "https://files.pythonhosted.org/packages/df/9e/d1a7217f69310c1db8fdf8ab396229f55a699ce34a203691794c5d1cad0c/packaging-21.3.tar.gz"
sha256 "dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"
end
resource "pyparsing" do
url "https://files.pythonhosted.org/packages/71/22/207523d16464c40a0310d2d4d8926daffa00ac1f5b1576170a32db749636/pyparsing-3.0.9.tar.gz"
sha256 "2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"
end
resource "python-dateutil" do
url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz"
sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"
end
resource "zstandard" do
url "https://files.pythonhosted.org/packages/9a/50/1b7f7f710c0dfc1019ec4c7295f67855722c342af82f3132664ca6dc1c07/zstandard-0.19.0.tar.gz"
sha256 "31d12fcd942dd8dbf52ca5f6b1bbe287f44e5d551a081a983ff3ea2082867863"
end
def python3
"python3.11"
end
def install
# Linux build is not thread-safe.
ENV.deparallelize unless OS.mac?
system "autoreconf", "--force", "--install", "--verbose"
site_packages = Language::Python.site_packages(python3)
xy = Language::Python.major_minor_version(python3)
venv = virtualenv_create(libexec, python3)
venv.pip_install resources
%w[fonttools].each do |package_name|
package = Formula[package_name].opt_libexec
(libexec/site_packages/"homebrew-#{package_name}.pth").write package/site_packages
end
args = %W[
PYTHON=#{python3}
--with-python-module-path=#{prefix/site_packages}
--with-boost-python=boost_python#{xy.to_s.delete(".")}-mt
--with-boost-libdir=#{Formula["boost"].opt_lib}
--with-boost-coroutine=boost_coroutine-mt
]
args << "--with-expat=#{MacOS.sdk_path}/usr" if MacOS.sdk_path_if_needed
args << "PYTHON_LIBS=-undefined dynamic_lookup" if OS.mac?
system "./configure", *std_configure_args, *args
system "make", "install"
pth_contents = "import site; site.addsitedir('#{libexec/site_packages}')\n"
(prefix/site_packages/"homebrew-graph-tool.pth").write pth_contents
end
test do
(testpath/"test.py").write <<~EOS
import graph_tool as gt
g = gt.Graph()
v1 = g.add_vertex()
v2 = g.add_vertex()
e = g.add_edge(v1, v2)
assert g.num_edges() == 1
assert g.num_vertices() == 2
EOS
system python3, "test.py"
end
end