## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global srcname mplcairo

Name:           python-%{srcname}
Version:        0.6.1
Release:        %autorelease
Summary:        A (new) cairo backend for Matplotlib

License:        MIT
URL:            https://github.com/matplotlib/mplcairo
Source:         %pypi_source %{srcname}
# Skip upstream's -Werror configuration.
Patch:          0001-Don-t-error-on-all-warnings-in-tests.patch

# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch: %{ix86}

BuildRequires:  gcc-c++

%description
This is a new, essentially complete implementation of a cairo backend for
Matplotlib. It can be used in combination with a Qt5, GTK3, Tk, wx, or macOS
UI, or noninteractively (i.e., to save figure to various file formats).
Noteworthy points include:
  - Improved accuracy (e.g., with marker positioning, quad meshes, and text
    kerning).
  - Support for a wider variety of font formats, such as otf and pfb, for vector
    (PDF, PS, SVG) backends (Matplotlib's Agg backend also supports such fonts).
  - Optional support for complex text layout (right-to-left languages, etc.)
    using Raqm.
  - Support for embedding URLs in PDF (but not SVG) output.
  - Support for multi-page output both for PDF and PS (Matplotlib only supports
    multi-page PDF).
  - Support for custom blend modes (see `examples/operators.py`).


%package -n     python3-%{srcname}
Summary:        %{summary}

BuildRequires:  pkgconfig(cairo) >= 1.15.4
BuildRequires:  freetype-devel
BuildRequires:  pkgconfig(raqm) >= 0.7.0
BuildRequires:  python3-devel
BuildRequires:  python3-matplotlib-test-data >= 2.2
BuildRequires:  python3dist(pytest) >= 3.2.2
BuildRequires:  python3dist(pytest-xdist)
BuildRequires:  python3dist(sphinx)

BuildRequires:  font(dejavusans)
BuildRequires:  font(notosanscjkjp)
BuildRequires:  font(wenquanyizenhei)

# LaTeX dependencies for tests, copied from python-matplotlib.
BuildRequires:  texlive-collection-basic
BuildRequires:  texlive-collection-fontsrecommended
BuildRequires:  texlive-collection-latex
BuildRequires:  texlive-collection-latexrecommended
BuildRequires:  texlive-dvipng
BuildRequires:  texlive-latex-bin
BuildRequires:  texlive-luahbtex
BuildRequires:  texlive-tex-bin
BuildRequires:  texlive-xetex-bin
# Search for documentclass and add the classes here.
BuildRequires:  tex(article.cls)
# Search for inputenc and add any encodings used with it.
BuildRequires:  tex(utf8.def)
BuildRequires:  tex(utf8x.def)
# Found with: rg -Io 'usepackage(\[.+\])?\{.+\}' lib | rg -o '\{.+\}' | sort -u
# and then removing duplicates in one line, etc.
BuildRequires:  tex(avant.sty)
BuildRequires:  tex(chancery.sty)
BuildRequires:  tex(charter.sty)
BuildRequires:  tex(chemformula.sty)
BuildRequires:  tex(color.sty)
BuildRequires:  tex(courier.sty)
BuildRequires:  tex(fontenc.sty)
BuildRequires:  tex(fontspec.sty)
BuildRequires:  tex(geometry.sty)
BuildRequires:  tex(graphicx.sty)
BuildRequires:  tex(helvet.sty)
BuildRequires:  tex(hyperref.sty)
BuildRequires:  tex(import.sty)
BuildRequires:  tex(inputenc.sty)
BuildRequires:  tex(lmodern.sty)
BuildRequires:  tex(mathpazo.sty)
BuildRequires:  tex(mathptmx.sty)
BuildRequires:  tex(pgf.sty)
BuildRequires:  tex(sfmath.sty)
BuildRequires:  tex(textcomp.sty)
BuildRequires:  tex(txfonts.sty)
BuildRequires:  tex(type1cm.sty)
BuildRequires:  tex(type1ec.sty)
BuildRequires:  tex(underscore.sty)
# See BakomaFonts._fontmap in lib/matplotlib/mathtext.py
BuildRequires:  tex(cmb10.tfm)
BuildRequires:  tex(cmex10.tfm)
BuildRequires:  tex(cmmi10.tfm)
BuildRequires:  tex(cmr10.tfm)
BuildRequires:  tex(cmss10.tfm)
BuildRequires:  tex(cmsy10.tfm)
BuildRequires:  tex(cmtt10.tfm)

Requires:       cairo >= 1.15.4
Requires:       libraqm >= 0.7.0

%description -n python3-%{srcname}
This is a new, essentially complete implementation of a cairo backend for
Matplotlib. It can be used in combination with a Qt5, GTK3, Tk, wx, or macOS
UI, or noninteractively (i.e., to save figure to various file formats).
Noteworthy points include:
  - Improved accuracy (e.g., with marker positioning, quad meshes, and text
    kerning).
  - Support for a wider variety of font formats, such as otf and pfb, for vector
    (PDF, PS, SVG) backends (Matplotlib's Agg backend also supports such fonts).
  - Optional support for complex text layout (right-to-left languages, etc.)
    using Raqm.
  - Support for embedding URLs in PDF (but not SVG) output.
  - Support for multi-page output both for PDF and PS (Matplotlib only supports
    multi-page PDF).
  - Support for custom blend modes (see `examples/operators.py`).


%prep
%autosetup -n %{srcname}-%{version} -p1

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{srcname}

%check
# We need to prime this LaTeX cache stuff, or it might fail while running tests
# in parallel.
mktexfmt latex.fmt
mktexfmt lualatex.fmt
mktexfmt pdflatex.fmt
mktexfmt xelatex.fmt

export %{py3_test_envvars}

%{python3} -c 'import mplcairo.base'

MPLBACKEND=module://mplcairo.base %{python3} - <<EOF
import matplotlib.pyplot as plt
print(plt.get_backend())
fig, ax = plt.subplots()
fig.savefig("/dev/null", format="png")
EOF

# 50 is upstream recommended tolerance since results won't match MPL exactly.
%{python3} run-mpl-test-suite.py --tolerance=50 -m 'not network' -v -n auto \
    -k 'not test_backends_interactive'

%files -n python3-%{srcname} -f %{pyproject_files}
%doc README.rst
%license LICENSE.txt
%{python3_sitearch}/%{srcname}.pth

%changelog
## START: Generated by rpmautospec
* Tue Nov 12 2024 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.6.1-1
- Update to latest version (#2323318)

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 0.5-11
- Rebuilt for Python 3.13

* Tue Jan 30 2024 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.5-10
- Backport fix to build against latest wheel

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue Jun 27 2023 Python Maint <python-maint@redhat.com> - 0.5-6
- Rebuilt for Python 3.12

* Tue Jan 24 2023 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.5-5
- Update test dependencies to match current Matplotlib

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Mon Dec 19 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.5-3
- Backport compatibility fix for latest setuptools

* Mon Dec 19 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.5-2
- Drop support for i686

* Sat Aug 20 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.5-1
- Update to latest version (#2119361)

* Sat Aug 20 2022 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.4-10
- Switch to latest Python macros

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed Jun 15 2022 Python Maint <python-maint@redhat.com> - 0.4-5
- Rebuilt for Python 3.11

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.4-2
- Rebuilt for Python 3.10

* Fri Apr 02 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.4-1
- Update to latest version (#1945883)

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.3-4
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu Jul 02 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.3-2
- Backport fix for Matplotlib 3.3.0rc1

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.3-2
- Rebuilt for Python 3.9

* Mon May 04 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.3-1
- Update to latest version

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Mon Sep 23 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.2-1
- Update to latest version

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.1-4
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Jul 23 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.1-1
- Update to final release

* Mon Apr 16 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.1-0.2.a1
- Remove bundled eggs.
- Add checks and missing Requires.

* Tue Mar 13 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.1-0.1.a1
- Initial package.

## END: Generated by rpmautospec