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/8a/76/d3c6e3a13fe484ebe7718d14e269c9569c4eb0020a968a327acb3b9a8fe6/matplotlib-3.10.8.tar.gz" sha256 "2299372c19d56bcd35cf05a2738308758d32b9eaed2371898d8f5bd33f084aa3" license "PSF-2.0" bottle do sha256 cellar: :any, arm64_tahoe: "3fcf17aae7bce1bc0f60593d06da0262bdbe8d47ab9e052fc89d9d8529272e4b" sha256 cellar: :any, arm64_sequoia: "df47a4b2cefd9c8cd550f6b5628a8b909cba21109f0697fe81057bc2d65477ec" sha256 cellar: :any, arm64_sonoma: "ad93838423e4ca044002d160d5f2003c2901e213736ac3a66e85f37b1078d405" sha256 cellar: :any, sonoma: "6f2a62c931e3a70c3234a2dab29b6cb72fe834cfd1c72338a30cd7d8c5c0d4f3" sha256 cellar: :any_skip_relocation, arm64_linux: "cc423cb522c0dc6746a2a4aab561d56893cbde080a78e28a6333b1957d090997" sha256 cellar: :any_skip_relocation, x86_64_linux: "26b228caf6e0ddc4f67b283a9598982c6bbae482c6026e7012c9b579ae0e3135" end depends_on "cmake" => :build # for contourpy depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkgconf" => :build depends_on "freetype" depends_on "numpy" depends_on "pillow" => :no_linkage depends_on "python@3.14" depends_on "qhull" on_linux do depends_on "patchelf" => :build end pypi_packages exclude_packages: %w[numpy pillow] resource "contourpy" do url "https://files.pythonhosted.org/packages/58/01/1253e6698a07380cd31a736d248a3f2a50a7c88779a1813da27503cadc2a/contourpy-1.3.3.tar.gz" sha256 "083e12155b210502d0bca491432bb04d56dc3432f95a979b429f2848c3dbe880" 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/33/f9/0e84d593c0e12244150280a630999835a64f2852276161b62a0f98318de0/fonttools-4.61.0.tar.gz" sha256 "ec520a1f0c7758d7a858a00f090c1745f6cde6a7c5e76fb70ea4044a15f712e7" end resource "kiwisolver" do url "https://files.pythonhosted.org/packages/5c/3c/85844f1b0feb11ee581ac23fe5fce65cd049a200c1446708cc1b7f922875/kiwisolver-1.4.9.tar.gz" sha256 "c3b22c26c6fd6811b0ae8363b95ca8ce4ea3c202d3d0975b2914310ceb1bcc4d" 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/f2/a5/181488fc2b9d093e3972d2a472855aae8a03f000592dbfce716a512b3359/pyparsing-3.2.5.tar.gz" sha256 "2df8d5b7b2802ef88e8d016a2eb9c7aeaa923529cd251ed0fe4608275d4105b6" 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.14") 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