1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 PYTHON_REQ_USE='tk?,threads(+)'
9 DISTUTILS_USE_SETUPTOOLS=bdepend
11 inherit distutils-r1 flag-o-matic virtualx toolchain-funcs prefix
13 DESCRIPTION="Pure python plotting library with matlab like syntax"
14 HOMEPAGE="https://matplotlib.org/"
15 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
18 # Main license: matplotlib
20 # matplotlib/backends/qt4_editor: MIT
21 # Fonts: BitstreamVera, OFL-1.1
22 LICENSE="BitstreamVera BSD matplotlib MIT OFL-1.1"
23 KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
24 IUSE="cairo doc excel examples gtk3 latex qt5 tk wxwidgets"
28 cairo latex qt5 tk wxwidgets gtk3
32 # internal copy of pycxx highly patched
36 >=dev-python/cycler-0.10.0-r1[${PYTHON_USEDEP}]
37 >=dev-python/kiwisolver-1.2.0[${PYTHON_USEDEP}]
38 >=dev-python/numpy-1.18.2[${PYTHON_USEDEP}]
39 >=dev-python/pyparsing-1.5.6[${PYTHON_USEDEP}]
40 dev-python/python-dateutil:0[${PYTHON_USEDEP}]
41 >=dev-python/pytz-2019.3[${PYTHON_USEDEP}]
42 >=dev-python/six-1.14.0[${PYTHON_USEDEP}]
43 dev-python/versioneer[${PYTHON_USEDEP}]
45 media-fonts/stix-fonts
48 >=media-libs/qhull-2013
49 >=www-servers/tornado-6.0.4[${PYTHON_USEDEP}]
51 dev-python/cairocffi[${PYTHON_USEDEP}]
54 dev-python/xlwt[${PYTHON_USEDEP}]
57 dev-python/pygobject:3[cairo?,${PYTHON_USEDEP}]
58 x11-libs/gtk+:3[introspection]
63 app-text/ghostscript-gpl
64 app-text/poppler[utils]
65 dev-texlive/texlive-fontsrecommended
66 dev-texlive/texlive-latexextra
67 dev-texlive/texlive-xetex
70 dev-python/PyQt5[gui,widgets,${PYTHON_USEDEP}]
73 dev-python/wxpython:*[${PYTHON_USEDEP}]
81 >=app-text/dvipng-1.15-r1
82 >=dev-python/colorspacious-1.1.2[${PYTHON_USEDEP}]
83 >=dev-python/pillow-7.1.1[${PYTHON_USEDEP}]
84 >=dev-python/ipython-1.18.2[${PYTHON_USEDEP}]
85 >=dev-python/numpydoc-0.9.2[${PYTHON_USEDEP}]
86 >=sci-libs/scipy-1.4.1[${PYTHON_USEDEP}]
87 >=dev-python/sphinx-1.3.1[${PYTHON_USEDEP}]
88 >=dev-python/sphinx-gallery-0.3.1-r1[${PYTHON_USEDEP}]
89 >=dev-python/xlwt-1.3.0-r1[${PYTHON_USEDEP}]
90 dev-texlive/texlive-latexextra
91 dev-texlive/texlive-fontsrecommended
92 dev-texlive/texlive-latexrecommended
93 >=media-gfx/graphviz-2.42.3[cairo]
95 test? ( dev-python/mock[${PYTHON_USEDEP}] )
98 # A few C++ source files are written to srcdir.
99 # Other than that, the ebuild shall be fit for out-of-source build.
100 DISTUTILS_IN_SOURCE_BUILD=1
102 distutils_enable_tests nose
105 unset DISPLAY # bug #278524
109 local uword="${2:-${1}}"
111 echo "${uword} = True"
112 echo "${uword}agg = True"
114 echo "${uword} = False"
115 echo "${uword}agg = False"
119 python_prepare_all() {
120 # Generates test failures, but fedora does it
122 # "${FILESDIR}"/${P}-unbundle-pycxx.patch
123 # "${FILESDIR}"/${P}-unbundle-agg.patch
125 # rm -r agg24 CXX || die
128 # cat > lib/${PN}/externals/six.py <<-EOF
129 # from __future__ import absolute_import
134 "${FILESDIR}"/${PN}-3.1.2-qhull.patch
138 -e 's/matplotlib.pyparsing_py[23]/pyparsing/g' \
139 -i lib/matplotlib/{mathtext,fontconfig_pattern}.py \
140 || die "sed pyparsing failed"
142 hprefixify setupext.py
144 rm -rf libqhull || die
146 export XDG_RUNTIME_DIR="${T}/runtime-dir"
147 mkdir "${XDG_RUNTIME_DIR}" || die
148 chmod 0700 "${XDG_RUNTIME_DIR}" || die
150 local freetype_version
151 freetype_version="$(best_version media-libs/freetype | sed -r -e 's/.*-([0-9].*[0-9])(-r[0-9]+|$)/\1/g')"
152 sed -i -r -e "s:(LOCAL_FREETYPE_VERSION =).*:\\1 \"${freetype_version}\":g" setupext.py lib/matplotlib/__init__.py || die
154 distutils-r1_python_prepare_all
157 python_configure_all() {
158 append-flags -fno-strict-aliasing
159 append-cppflags -DNDEBUG # or get old trying to do triangulation
164 mkdir -p "${BUILD_DIR}" || die
166 # create setup.cfg (see setup.cfg.template for any changes).
169 cat > "${BUILD_DIR}"/setup.cfg <<- EOF || die
171 basedirlist = ${EPREFIX}/usr
176 tests = $(usex test True False)
189 if use gtk3 && use cairo; then
190 echo "gtk3cairo = True" >> "${BUILD_DIR}"/setup.cfg || die
192 echo "gtk3cairo = False" >> "${BUILD_DIR}"/setup.cfg || die
195 if python_is_python3; then
196 cat >> "${BUILD_DIR}"/setup.cfg <<- EOF || die
203 cat >> "${BUILD_DIR}"/setup.cfg <<-EOF || die
204 $(use_setup gtk2 gtk)
205 $(use_setup wxwidgets wx)
212 local -x MPLSETUPCFG="${BUILD_DIR}"/setup.cfg
218 wrap_setup distutils-r1_python_compile --build-lib="${BUILD_DIR}"/lib
221 python_compile_all() {
225 # necessary for in-source build
226 local -x PYTHONPATH="${BUILD_DIR}"/build/lib:${PYTHONPATH}
228 VARTEXFONTS="${T}"/fonts \
229 emake SPHINXOPTS= O=-Dplot_formats=png:100 html
234 wrap_setup distutils_install_for_testing
236 distutils_install_for_testing
237 "${EPYTHON}" -c "import sys, matplotlib as m; sys.exit(0 if m.test(verbosity=2) else 1)" || die
241 wrap_setup distutils-r1_python_install
243 # mpl_toolkits namespace
244 python_moduleinto mpl_toolkits
245 python_domodule lib/mpl_toolkits/__init__.py
248 python_install_all() {
249 use doc && local HTML_DOCS=( doc/build/html/. )
251 distutils-r1_python_install_all
253 if use examples; then
255 docompress -x /usr/share/doc/${PF}/examples
258 find "${D}" -name '*.pth' -delete || die