class PythonMatplotlib < Formula include Language::Python::Virtualenv desc "Python library for creating static, animated, and interactive visualizations" homepage "https://matplotlib.org/" url "https://files.pythonhosted.org/packages/26/91/d49359a21893183ed2a5b6c76bec40e0b1dcbf8ca148f864d134897cfc75/matplotlib-3.10.3.tar.gz" sha256 "2f82d2c5bb7ae93aaaa4cd42aca65d76ce6376f83304fa3a630b569aca274df0" license "PSF-2.0" bottle do sha256 cellar: :any, arm64_sequoia: "f846f0a1c9d5d48422448f07e15a9dcd0daebefac582812edfb8ebd6cf2b7943" sha256 cellar: :any, arm64_sonoma: "0e570ef8a32efdcbba04f783a18f2b7c30323c69858d5800b824c116ac25b290" sha256 cellar: :any, arm64_ventura: "7faf623e8955a64ef19a948d333fdbe837c7d83d49c35117e3b880380a4bee21" sha256 cellar: :any, sonoma: "fc4ebc05b8a4a9ea3c54a9bc1d085ba379c3531fab651d45c6e0d2de76ef682e" sha256 cellar: :any, ventura: "8c4e8ef8163b0a475e15c64c9ae1130088ea44dae426cab338f1e367d9b3323d" sha256 cellar: :any_skip_relocation, arm64_linux: "33e103e653c5f859d61c6894c5e30634ceeb86fd6f2983061d237ad5d00d3fff" sha256 cellar: :any_skip_relocation, x86_64_linux: "4bd3e43699f52a0b9efa651e983d63cfff9520461647886c2807ef4e13ccc7dc" end depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkgconf" => :build depends_on "freetype" depends_on "numpy" depends_on "pillow" depends_on "python@3.13" depends_on "qhull" on_linux do depends_on "patchelf" => :build end resource "contourpy" do url "https://files.pythonhosted.org/packages/66/54/eb9bfc647b19f2009dd5c7f5ec51c4e6ca831725f1aea7a993034f483147/contourpy-1.3.2.tar.gz" sha256 "b6945942715a034c671b7fc54f9588126b0b8bf23db2696e3ca8328f3ff0ab54" end resource "cycler" do url "https://files.pythonhosted.org/packages/a9/95/a3dbbb5028f35eafb79008e7522a75244477d2838f38cbb722248dabc2a8/cycler-0.12.1.tar.gz" sha256 "88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c" end resource "fonttools" do url "https://files.pythonhosted.org/packages/03/2d/a9a0b6e3a0cf6bd502e64fc16d894269011930cabfc89aee20d1635b1441/fonttools-4.57.0.tar.gz" sha256 "727ece10e065be2f9dd239d15dd5d60a66e17eac11aea47d447f9f03fdbc42de" end resource "kiwisolver" do url "https://files.pythonhosted.org/packages/82/59/7c91426a8ac292e1cdd53a63b6d9439abd573c875c3f92c146767dd33faf/kiwisolver-1.4.8.tar.gz" sha256 "23d5f023bdc8c7e54eb65f03ca5d5bb25b601eac4d7f1a042888a1f45237987e" end resource "packaging" do url "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz" sha256 "d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f" end resource "pyparsing" do url "https://files.pythonhosted.org/packages/bb/22/f1129e69d94ffff626bdb5c835506b3a5b4f3d070f17ea295e12c2c6f60f/pyparsing-3.2.3.tar.gz" sha256 "b9c13f1ab8b3b542f72e28f634bad4de758ab3ce4546e4301970ad6fa77c38be" end resource "python-dateutil" do url "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz" sha256 "37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3" end resource "six" do url "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz" sha256 "ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81" end def python3 which("python3.13") end def install venv = virtualenv_create(libexec, python3) venv.pip_install resources system python3, "-m", "pip", "--python=#{venv.root}", "install", "--config-settings=setup-args=-Dsystem-freetype=true", "--config-settings=setup-args=-Dsystem-qhull=true", *std_pip_args(prefix: false, build_isolation: true), "." (prefix/Language::Python.site_packages(python3)/"homebrew-matplotlib.pth").write venv.site_packages end test do backend = shell_output("#{python3} -c 'import matplotlib; print(matplotlib.get_backend())'").chomp assert_equal OS.mac? ? "macosx" : "agg", backend end end