homebrew-core/Formula/graph-tool.rb

120 lines
4.5 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.44.tar.bz2"
sha256 "2dd8c31b65eb9404b78af1413d2c8896e247fa5bf81dfcbe56fcaa27af82df26"
license "LGPL-3.0-or-later"
livecheck do
url "https://downloads.skewed.de/graph-tool/"
regex(/href=.*?graph-tool[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_monterey: "4c6a0567338f06f700f69ac1800f1d9bf89ca39273fd18841bcc67a0292772d8"
sha256 arm64_big_sur: "e49b0f0c6a0ccff776e936ffe2581fd6c87fd215091476425842b94e8be65592"
sha256 monterey: "e5d41985629eec5f0d0565b6fbccf497334833fd989a88c30cc75e10a3058af5"
sha256 big_sur: "32550b73d3392976b554cb019edc977fd5962725c1c2113923feb45e0861de6c"
sha256 catalina: "15384530cd337b144787379876be83451a8cb360d8425732e96a8157c9b38d0d"
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 "google-sparsehash"
depends_on "gtk+3"
depends_on "librsvg"
depends_on macos: :mojave # for C++17
depends_on "numpy"
depends_on "py3cairo"
depends_on "pygobject3"
depends_on "python@3.9"
depends_on "scipy"
depends_on "six"
resource "Cycler" do
url "https://files.pythonhosted.org/packages/c2/4b/137dea450d6e1e3d474e1d873cd1d4f7d3beed7e0dc973b06e8e10d32488/cycler-0.10.0.tar.gz"
sha256 "cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8"
end
resource "kiwisolver" do
url "https://files.pythonhosted.org/packages/90/55/399ab9f2e171047d28933ae4b686d9382d17e6c09a01bead4a6f6b5038f4/kiwisolver-1.3.1.tar.gz"
sha256 "950a199911a8d94683a6b10321f9345d5a3a8433ec58b217ace979e18f16e248"
end
resource "matplotlib" do
url "https://files.pythonhosted.org/packages/60/d3/286925802edaeb0b8834425ad97c9564ff679eb4208a184533969aa5fc29/matplotlib-3.4.2.tar.gz"
sha256 "d8d994cefdff9aaba45166eb3de4f5211adb4accac85cbf97137e98f26ea0219"
end
resource "pyparsing" do
url "https://files.pythonhosted.org/packages/c1/47/dfc9c342c9842bbe0036c7f763d2d6686bcf5eb1808ba3e170afdb282210/pyparsing-2.4.7.tar.gz"
sha256 "c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"
end
resource "python-dateutil" do
url "https://files.pythonhosted.org/packages/be/ed/5bbc91f03fa4c839c4c7360375da77f9659af5f7086b7a7bdda65771c8e0/python-dateutil-2.8.1.tar.gz"
sha256 "73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"
end
resource "pytz" do
url "https://files.pythonhosted.org/packages/b0/61/eddc6eb2c682ea6fd97a7e1018a6294be80dba08fa28e7a3570148b4612d/pytz-2021.1.tar.gz"
sha256 "83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da"
end
resource "zstandard" do
url "https://files.pythonhosted.org/packages/b4/79/7b192e51a2952dee3a3c9dbd9208a9838d8d497745a18a5528e2dbfb465e/zstandard-0.15.2.tar.gz"
sha256 "52de08355fd5cfb3ef4533891092bb96229d43c2069703d4aff04fdbedf9c92f"
end
def install
system "autoreconf", "-fiv"
xy = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
venv = virtualenv_create(libexec, Formula["python@3.9"].opt_bin/"python3")
resources.each do |r|
venv.pip_install_and_link r
end
args = [
"--disable-debug",
"--disable-dependency-tracking",
"--prefix=#{prefix}",
"PYTHON=python3",
"PYTHON_LIBS=-undefined dynamic_lookup",
"--with-python-module-path=#{lib}/python#{xy}/site-packages",
"--with-boost-python=boost_python#{xy.to_s.delete(".")}-mt",
"--with-boost-libdir=#{HOMEBREW_PREFIX}/opt/boost/lib",
"--with-boost-coroutine=boost_coroutine-mt",
]
args << "--with-expat=#{MacOS.sdk_path}/usr" if MacOS.sdk_path_if_needed
system "./configure", *args
system "make", "install"
site_packages = "lib/python#{xy}/site-packages"
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 Formula["python@3.9"].opt_bin/"python3", "test.py"
end
end