py-matplotlib: add v3.9.0 (#44225)

This commit is contained in:
Adam J. Stewart 2024-05-20 09:22:30 +02:00 committed by GitHub
parent 419f0742a0
commit dcd6b530f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,7 +16,6 @@ class PyMatplotlib(PythonPackage):
homepage = "https://matplotlib.org/"
pypi = "matplotlib/matplotlib-3.3.2.tar.gz"
maintainers("adamjstewart")
skip_modules = [
"matplotlib.tests",
"mpl_toolkits.axes_grid1.tests",
@ -25,12 +24,15 @@ class PyMatplotlib(PythonPackage):
]
license("Apache-2.0")
maintainers("adamjstewart", "rgommers")
version("3.9.0", sha256="e6d29ea6c19e34b30fb7d88b7081f869a03014f66fe06d62cc77d5a6ea88ed7a")
version("3.8.4", sha256="8aac397d5e9ec158960e31c381c5ffc52ddd52bd9a47717e2a694038167dffea")
version("3.8.3", sha256="7b416239e9ae38be54b028abbf9048aff5054a9aba5416bef0bd17f9162ce161")
version("3.8.2", sha256="01a978b871b881ee76017152f1f1a0cbf6bd5f7b8ff8c96df0df1bd57d8755a1")
version("3.8.1", sha256="044df81c1f6f3a8e52d70c4cfcb44e77ea9632a10929932870dfaa90de94365d")
version("3.8.0", sha256="df8505e1c19d5c2c26aff3497a7cbd3ccfc2e97043d1e4db3e76afa399164b69")
version("3.7.5", sha256="1e5c971558ebc811aa07f54c7b7c677d78aa518ef4c390e14673a09e0860184a")
version("3.7.4", sha256="7cd4fef8187d1dd0d9dcfdbaa06ac326d396fb8c71c647129f0bf56835d77026")
version("3.7.3", sha256="f09b3dd6bdeb588de91f853bbb2d6f0ff8ab693485b0c49035eaa510cb4f142e")
version("3.7.2", sha256="a8cdb91dddb04436bd2f098b8fdf4b81352e68cf4d2c6756fcc414791076569b")
@ -60,7 +62,9 @@ class PyMatplotlib(PythonPackage):
version("3.1.2", sha256="8e8e2c2fe3d873108735c6ee9884e6f36f467df4a143136209cff303b183bada")
version("3.1.1", sha256="1febd22afe1489b13c6749ea059d392c03261b2950d1d45c17e3aed812080c93")
version("3.1.0", sha256="1e0213f87cc0076f7b0c4c251d7e23601e2419cd98691df79edb95517ba06f0c")
version("3.0.3", sha256="e1d33589e32f482d0a7d1957bf473d43341115d40d33f578dad44432e47df7b7")
version("3.0.2", sha256="c94b792af431f6adb6859eb218137acd9a35f4f7442cea57e4a59c54751c36af")
version("3.0.1", sha256="70f8782c50ac2c7617aad0fa5ba59fc49f690a851d6afc0178813c49767644dd")
version("3.0.0", sha256="b4e2333c98a7c2c1ff6eb930cd2b57d4b818de5437c5048802096b32f66e65f9")
version(
"2.2.5",
@ -94,8 +98,9 @@ class PyMatplotlib(PythonPackage):
)
# https://matplotlib.org/stable/users/explain/figure/backends.html
# From `lib/matplotlib/rcsetup.py`:
interactive_bk = [
# matplotlib 3.9+: lib/matplotlib/backends/registry.py
# matplotlib 3.8-: lib/matplotlib/rcsetup.py
all_backends = [
# GTK
conditional("gtk", when="@:2"),
conditional("gtkagg", when="@:2"),
@ -104,6 +109,11 @@ class PyMatplotlib(PythonPackage):
"gtk3cairo",
conditional("gtk4agg", when="@3.5:"),
conditional("gtk4cairo", when="@3.5:"),
# Cocoa
"macosx",
# Jupyter Notebook
"nbagg",
conditional("notebook", when="@3.9:"),
# Qt
conditional("qtagg", when="@3.5:"),
conditional("qtcairo", when="@3.5:"),
@ -114,16 +124,13 @@ class PyMatplotlib(PythonPackage):
# Tk
"tkagg",
"tkcairo",
# WebAgg
"webagg",
# Wx
"wx",
"wxagg",
conditional("wxcairo", when="@2.2:"),
# Other
"macosx",
"nbagg",
"webagg",
]
non_interactive_bk = [
# Headless
"agg",
"cairo",
conditional("gdk", when="@:2"),
@ -133,7 +140,6 @@ class PyMatplotlib(PythonPackage):
"svg",
"template",
]
all_backends = interactive_bk + non_interactive_bk
default_backend = "agg"
if sys.platform == "darwin":
@ -158,7 +164,7 @@ class PyMatplotlib(PythonPackage):
variant("latex", default=False, description="Enable LaTeX text rendering support")
variant("fonts", default=False, description="Enable support for system font detection")
# https://matplotlib.org/stable/users/installing/dependencies.html
# https://matplotlib.org/stable/install/dependencies.html
# Runtime dependencies
# Mandatory dependencies
depends_on("python@3.9:", when="@3.8:", type=("build", "link", "run"))
@ -169,7 +175,8 @@ class PyMatplotlib(PythonPackage):
depends_on("py-fonttools@4.22:", when="@3.5:", type=("build", "run"))
depends_on("py-kiwisolver@1.3.1:", when="@3.8.1:", type=("build", "run"))
depends_on("py-kiwisolver@1.0.1:", when="@2.2:", type=("build", "run"))
depends_on("py-numpy@1.21:", when="@3.8.4:", type=("build", "link", "run"))
depends_on("py-numpy@1.23:", when="@3.9:", type=("build", "link", "run"))
depends_on("py-numpy@1.21:", when="@3.8.4", type=("build", "link", "run"))
depends_on("py-numpy@1.21:1", when="@3.8.0:3.8.3", type=("build", "link", "run"))
depends_on("py-numpy@1.20:1", when="@3.7", type=("build", "link", "run"))
depends_on("py-numpy@1.19:1", when="@3.6", type=("build", "link", "run"))
@ -197,7 +204,9 @@ class PyMatplotlib(PythonPackage):
# Backends
# Tk
for backend in ["tkagg", "tkcairo"]:
depends_on("tk@8.4:8.5,8.6.2:", when="backend=" + backend, type="run")
depends_on("tk@8.5:", when="@3.8: backend=" + backend, type="run")
depends_on("tk@8.4:", when="@3.5: backend=" + backend, type="run")
depends_on("tk@8.3:", when="backend=" + backend, type="run")
depends_on("python+tkinter", when="backend=" + backend, type="run")
# Qt
# matplotlib/backends/qt_compat.py
@ -213,7 +222,9 @@ class PyMatplotlib(PythonPackage):
# GTK
for backend in ["gtk", "gtkagg", "gtkcairo", "gtk3agg", "gtk3cairo", "gtk4agg", "gtk4cairo"]:
depends_on("py-pygobject", when="backend=" + backend, type="run")
depends_on("py-pycairo@1.14:", when="backend=" + backend, type="run")
depends_on("py-pycairo@1.14:", when="@3.6: backend=" + backend, type="run")
depends_on("py-pycairo@1.11:", when="@3.3: backend=" + backend, type="run")
depends_on("py-pycairo", when="backend=" + backend, type="run")
# Cairo
for backend in [
"gtkcairo",
@ -226,12 +237,15 @@ class PyMatplotlib(PythonPackage):
"wxcairo",
"cairo",
]:
depends_on("py-pycairo@1.14:", when="backend=" + backend, type="run")
depends_on("py-pycairo@1.14:", when="@3.6: backend=" + backend, type="run")
depends_on("py-pycairo@1.11:", when="@3.3: backend=" + backend, type="run")
depends_on("py-pycairo", when="backend=" + backend, type="run")
# Wx
for backend in ["wx", "wxagg", "wxcairo"]:
depends_on("py-wxpython@4:", when="backend=" + backend, type="run")
# Other
depends_on("py-tornado@5:", when="backend=webagg", type="run")
depends_on("py-tornado@5:", when="@3.5: backend=webagg", type="run")
depends_on("py-tornado", when="backend=webagg", type="run")
depends_on("py-ipykernel", when="backend=nbagg", type="run")
# Optional dependencies
@ -253,15 +267,18 @@ class PyMatplotlib(PythonPackage):
# Dependencies for building matplotlib
# Setup dependencies
depends_on("py-certifi@2020.6.20:", when="@3.3.1:", type="build")
depends_on("py-numpy@1.25:", when="@3.8:", type="build")
depends_on("py-pybind11@2.6:", when="@3.7:", type="build")
depends_on("py-setuptools@64:", when="@3.8.1:", type="build")
depends_on("py-setuptools@42:", when="@3.8:", type="build")
depends_on("py-setuptools@42:", when="@3.7.2:3.7", type=("build", "run"))
depends_on("py-setuptools", when="@:3.7.1", type=("build", "run"))
depends_on("py-meson-python@0.13.1:", when="@3.9:", type="build")
depends_on("ninja@1.8.2:", when="@3.9:", type="build")
depends_on("py-pybind11@2.6:", when="@3.7:", type=("build", "link"))
depends_on("py-setuptools-scm@7:", when="@3.6:", type="build")
depends_on("py-setuptools-scm@4:6", when="@3.5", type="build")
# Historical dependencies
depends_on("py-certifi@2020.6.20:", when="@3.3.1:3.8", type="build")
depends_on("py-setuptools@64:", when="@3.8.1:3.8", type="build")
depends_on("py-setuptools@42:", when="@3.8.0", type="build")
depends_on("py-setuptools@42:", when="@3.7.2:3.7", type=("build", "run"))
depends_on("py-setuptools", when="@:3.7.1", type=("build", "run"))
depends_on("py-setuptools-scm-git-archive", when="@3.5", type="build")
# Testing dependencies
@ -275,19 +292,21 @@ class PyMatplotlib(PythonPackage):
conflicts("platform=cray", when="backend=macosx", msg=msg)
conflicts("platform=windows", when="backend=macosx", msg=msg)
conflicts("^tk@8.6.0:8.6.1")
# https://github.com/matplotlib/matplotlib/pull/21662
patch("matplotlibrc.patch", when="@3.5.0")
# Patch to pick up correct freetype headers
patch("freetype-include-path.patch", when="@2.2.2:2.9.9")
@property
def config_file(self):
# https://github.com/matplotlib/matplotlib/pull/20871
return "mplsetup.cfg" if self.spec.satisfies("@3.5:") else "setup.cfg"
@property
def archive_files(self):
return [os.path.join(self.build_directory, self.config_file)]
if self.spec.satisfies("@3.9:"):
return [os.path.join(self.stage.source_path, "build", "meson-logs", "meson-log.txt")]
elif self.spec.satisfies("@3.5:"):
return [os.path.join(self.build_directory, "mplsetup.cfg")]
else:
return [os.path.join(self.build_directory, "setup.cfg")]
def flag_handler(self, name, flags):
if name == "cxxflags":
@ -295,40 +314,19 @@ def flag_handler(self, name, flags):
flags.append("-Wno-error=register")
return (flags, None, None)
def setup_build_environment(self, env):
include = []
library = []
for dep in self.spec.dependencies(deptype="link"):
query = self.spec[dep.name]
include.extend(query.headers.directories)
library.extend(query.libs.directories)
# Build uses a mix of Spack's compiler wrapper and the actual compiler,
# so this is needed to get parts of the build working.
# See https://github.com/spack/spack/issues/19843
env.set("CPATH", ":".join(include))
env.set("LIBRARY_PATH", ":".join(library))
@run_before("install")
def configure(self):
"""Set build options with regards to backend GUI libraries."""
backend = self.spec.variants["backend"].value
with open(self.config_file, "w") as config:
# Default backend
config.write("[rc_options]\n")
config.write("backend = " + backend + "\n")
# Starting with version 3.3.0, freetype is downloaded by default
# Force matplotlib to use Spack installations of freetype and qhull
if self.spec.satisfies("@3.3:"):
config.write("[libs]\n")
config.write("system_freetype = True\n")
config.write("system_qhull = True\n")
# avoids error where link time opt is used for compile but not link
if self.spec.satisfies("%clang") or self.spec.satisfies("%oneapi"):
config.write("enable_lto = False\n")
@when("@3.9:")
def config_settings(self, spec, prefix):
return {
"builddir": "build",
"compile-args": f"-j{make_jobs}",
"setup-args": {
"-Dsystem-freetype": True,
"-Dsystem-qhull": True,
"-DrcParams-backend": spec.variants["backend"].value,
# Avoids error where link time opt is used for compile but not link
"-Db_lto": not (self.spec.satisfies("%clang") or self.spec.satisfies("%oneapi")),
},
}
@run_after("install")
@on_package_attributes(run_tests=True)
@ -360,3 +358,48 @@ def install_test(self):
python("-m", "pytest", "--pyargs", f"mpl_toolkits.{toolkit}.tests")
else:
python("-m", "pytest", "--pyargs", "mpl_toolkits.tests")
@when("@:3.8")
def setup_build_environment(self, env):
include = []
library = []
for dep in self.spec.dependencies(deptype="link"):
query = self.spec[dep.name]
include.extend(query.headers.directories)
try:
library.extend(query.libs.directories)
except spack.error.NoLibrariesError:
pass
# Build uses a mix of Spack's compiler wrapper and the actual compiler,
# so this is needed to get parts of the build working.
# See https://github.com/spack/spack/issues/19843
env.set("CPATH", ":".join(include))
env.set("LIBRARY_PATH", ":".join(library))
@when("@:3.8")
@run_before("install")
def configure(self):
"""Set build options with regards to backend GUI libraries."""
backend = self.spec.variants["backend"].value
if self.spec.satisfies("@3.5:"):
config_file = "mplsetup.cfg"
else:
config_file = "setup.cfg"
with open(config_file, "w") as config:
# Default backend
config.write("[rc_options]\n")
config.write("backend = " + backend + "\n")
# Starting with version 3.3.0, freetype is downloaded by default
# Force matplotlib to use Spack installations of freetype and qhull
if self.spec.satisfies("@3.3:"):
config.write("[libs]\n")
config.write("system_freetype = True\n")
config.write("system_qhull = True\n")
# avoids error where link time opt is used for compile but not link
if self.spec.satisfies("%clang") or self.spec.satisfies("%oneapi"):
config.write("enable_lto = False\n")