# Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 DISTUTILS_EXT=1 DISTUTILS_USE_PEP517=setuptools PYTHON_COMPAT=( python3_{10..11} ) PYTHON_REQ_USE='tk?,threads(+)' inherit distutils-r1 flag-o-matic multiprocessing prefix pypi inherit toolchain-funcs virtualx FT_PV=2.6.1 DESCRIPTION="Pure python plotting library with matlab like syntax" HOMEPAGE=" https://matplotlib.org/ https://github.com/matplotlib/matplotlib/ https://pypi.org/project/matplotlib/ " SRC_URI+=" test? ( https://downloads.sourceforge.net/project/freetype/freetype2/${FT_PV}/freetype-${FT_PV}.tar.gz ) " # Main license: matplotlib # Some modules: BSD # matplotlib/backends/qt4_editor: MIT # Fonts: BitstreamVera, OFL-1.1 LICENSE="BitstreamVera BSD matplotlib MIT OFL-1.1" SLOT="0" KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" IUSE="cairo doc excel examples gtk3 latex qt5 tk webagg wxwidgets" # internal copy of pycxx highly patched # dev-python/pycxx # # "${BUILD_DIR}"/setup.cfg <<- EOF || die [directories] basedirlist = ${EPREFIX}/usr [provide_packages] pytz = False dateutil = False [libs] system_freetype = True system_qhull = True [packages] tests = True [gui_support] agg = True gtk = False gtkagg = False macosx = False pyside = False pysideagg = False qt4 = False qt4agg = False $(use_setup cairo) $(use_setup gtk3) $(use_setup qt5) $(use_setup tk) $(use_setup wxwidgets wx) EOF if use gtk3 && use cairo; then echo "gtk3cairo = True" >> "${BUILD_DIR}"/setup.cfg || die else echo "gtk3cairo = False" >> "${BUILD_DIR}"/setup.cfg || die fi } wrap_setup() { local MAKEOPTS=-j1 local -x MPLSETUPCFG="${BUILD_DIR}"/setup.cfg "$@" } python_compile() { wrap_setup distutils-r1_python_compile find "${BUILD_DIR}" -name '*.pth' -delete || die } python_compile_all() { if use doc; then cd doc || die VARTEXFONTS="${T}"/fonts \ emake SPHINXOPTS= O=-Dplot_formats=png:100 html fi } src_test() { mkdir build || die ln -s "${WORKDIR}/freetype-${FT_PV}" build/ || die virtx distutils-r1_src_test } python_test() { local EPYTEST_DESELECT=( # broken by -Wdefault "tests/test_rcparams.py::test_validator_invalid[validate_strlist-arg6-MatplotlibDeprecationWarning]" "tests/test_rcparams.py::test_validator_invalid[validate_strlist-arg7-MatplotlibDeprecationWarning]" tests/test_testing.py::test_warn_to_fail # TODO? tests/test_backend_qt.py::test_fig_sigint_override # unhappy about xdist tests/test_widgets.py::test_span_selector_animated_artists_callback ) [[ ${EPYTHON} == python3.11 ]] && EPYTEST_DESELECT+=( # https://github.com/matplotlib/matplotlib/issues/23384 "tests/test_backends_interactive.py::test_figure_leak_20490[time_mem1-{'MPLBACKEND': 'qtagg', 'QT_API': 'PyQt5'}]" "tests/test_backends_interactive.py::test_figure_leak_20490[time_mem1-{'MPLBACKEND': 'qtcairo', 'QT_API': 'PyQt5'}]" ) # we need to rebuild mpl against bundled freetype, otherwise # over 1000 tests will fail because of mismatched font rendering grep -v system_freetype "${BUILD_DIR}"/setup.cfg \ > "${BUILD_DIR}"/test-setup.cfg || die local -x MPLSETUPCFG="${BUILD_DIR}"/test-setup.cfg esetup.py build -j1 --build-lib="${BUILD_DIR}"/test-lib local -x PYTHONPATH=${BUILD_DIR}/test-lib:${PYTHONPATH} # speed tests up local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 nonfatal epytest --pyargs matplotlib -m "not network" \ -p xdist.plugin -n "$(makeopts_jobs)" || die } python_install_all() { use doc && local HTML_DOCS=( doc/build/html/. ) distutils-r1_python_install_all if use examples; then dodoc -r examples docompress -x /usr/share/doc/${PF}/examples fi }