Skip to content

Commit 60fd825

Browse files
authored
Fix matplotlib minimal version corresponding to Ubuntu 24.04 (#25)
1 parent ebff8a6 commit 60fd825

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

mpl_typst/backend.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from tempfile import TemporaryDirectory
1212
from typing import IO, Any, Literal, Optional, Self, Type
1313

14+
import matplotlib as mpl
1415
import numpy as np
1516
from matplotlib import get_cachedir
1617
from matplotlib.backend_bases import (
@@ -22,10 +23,20 @@
2223
from matplotlib.path import Path
2324
from matplotlib.text import Text
2425
from matplotlib.transforms import Affine2DBase, Transform
25-
from matplotlib.typing import ColorType
2626
from numpy.typing import ArrayLike
2727
from PIL import Image, ImageOps
2828

29+
# Module `matplotlib.typing` has been introduced in matplotlib@3.8 but the
30+
# latest Ubuntu LTS 24.04 provides matplotlib@3.6. Since we are not ready to
31+
# abandont typing hints and support of the most popular distros is desirable,
32+
# we keep this version check until Ubuntu LTS 26.04.
33+
#
34+
# https://github.com/daskol/mpl-typst/issues/24
35+
if mpl.__version_info__ >= (3, 8):
36+
from matplotlib.typing import ColorType
37+
else:
38+
ColorType = Any
39+
2940
from mpl_typst.config import Config, compiler
3041
from mpl_typst.typst import (
3142
Array, Block, Call, Content, Dictionary, Scalar, Writer as TypstWriter)

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ classifiers = [
3333
"Topic :: Utilities",
3434
"Typing :: Typed",
3535
]
36-
dependencies = ["matplotlib", "numpy"]
36+
dependencies = [
37+
"matplotlib>=3.8",
38+
"numpy>=1.21",
39+
"numpy>=1.21.2; python_version>='3.10'",
40+
"numpy>=1.23.3; python_version>='3.11'",
41+
"numpy>=1.26.0; python_version>='3.12'",
42+
"numpy>=2.1.0; python_version>='3.13'",
43+
]
3744
requires-python = ">=3.11,<4"
3845

3946
[project.optional-dependencies]

0 commit comments

Comments
 (0)