blob: 889455d67812ebf9eed5364d124adc537a58341c [file] [log] [blame]
Mike Frysinger9c094e22015-05-14 18:19:25 -04001# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/dev-python/matplotlib/matplotlib-1.3.1.ebuild,v 1.2 2013/12/26 18:55:53 jlec Exp $
4
5EAPI=5
6
7PYTHON_COMPAT=( python{2_7,3_3} )
8
9PYTHON_REQ_USE='tk?'
10
11VIRTUALX_REQUIRED="always"
12
13inherit distutils-r1 eutils flag-o-matic virtualx toolchain-funcs
14
15DESCRIPTION="Pure python plotting library with matlab like syntax"
16HOMEPAGE="http://matplotlib.org/"
17SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
18
19SLOT="0"
20# Main license: matplotlib
21# Some modules: BSD
22# matplotlib/backends/qt4_editor: MIT
23# Fonts: BitstreamVera, OFL-1.1
24LICENSE="BitstreamVera BSD matplotlib MIT OFL-1.1"
25KEYWORDS="*"
26IUSE="cairo doc excel examples fltk gtk gtk3 latex pyside qt4 test tk wxwidgets"
27
28# #456704 -- a lot of py2-only deps
29PY2_USEDEP=$(python_gen_usedep 'python2*')
30PY3_USEDEP=$(python_gen_usedep python3_3)
31COMMON_DEPEND="
32 dev-python/numpy[${PYTHON_USEDEP}]
33 dev-python/python-dateutil:0[${PYTHON_USEDEP}]
34 dev-python/pytz[${PYTHON_USEDEP}]
35 dev-python/six[${PYTHON_USEDEP}]
36 media-fonts/stix-fonts
37 media-libs/freetype:2
38 media-libs/libpng:0
39 gtk? ( dev-python/pygtk[${PY2_USEDEP}] )
40 wxwidgets? ( >=dev-python/wxpython-2.8[${PY2_USEDEP}] )"
41
42# internal copy of pycxx highly patched
43# dev-python/pycxx
44
45DEPEND="${COMMON_DEPEND}
46 virtual/pkgconfig
47 doc? (
48 app-text/dvipng
49 virtual/python-imaging[${PYTHON_USEDEP}]
50 dev-python/ipython[${PYTHON_USEDEP}]
51 dev-python/numpydoc[${PY2_USEDEP}]
52 dev-python/xlwt[${PY2_USEDEP}]
53 dev-python/sphinx[${PYTHON_USEDEP}]
54 dev-texlive/texlive-latexextra
55 dev-texlive/texlive-fontsrecommended
56 dev-texlive/texlive-latexrecommended
57 media-gfx/graphviz[cairo]
58 )
59 test? ( dev-python/nose[${PYTHON_USEDEP}] )"
60
61RDEPEND="${COMMON_DEPEND}
62 dev-python/pyparsing[${PYTHON_USEDEP}]
63 cairo? ( dev-python/pycairo[${PYTHON_USEDEP}] )
64 excel? ( dev-python/xlwt[${PY2_USEDEP}] )
65 fltk? ( dev-python/pyfltk[${PY2_USEDEP}] )
66 gtk3? (
67 dev-python/pygobject:3[${PYTHON_USEDEP}]
68 x11-libs/gtk+:3[introspection] )
69 latex? (
70 virtual/latex-base
71 app-text/ghostscript-gpl
72 app-text/dvipng
73 app-text/poppler[utils]
74 dev-texlive/texlive-fontsrecommended
75 dev-texlive/texlive-latexextra
76 dev-texlive/texlive-xetex
77 )
78 pyside? ( dev-python/pyside[X,${PYTHON_USEDEP}] )
79 qt4? ( dev-python/PyQt4[X,${PYTHON_USEDEP}] )"
80
81PY2_FLAGS="|| ( $(python_gen_useflags python2*) )"
82REQUIRED_USE="
83 doc? ( ${PY2_FLAGS} )
84 excel? ( ${PY2_FLAGS} )
85 fltk? ( ${PY2_FLAGS} )
86 gtk? ( ${PY2_FLAGS} )
87 wxwidgets? ( ${PY2_FLAGS} )
88 test? (
89 cairo fltk latex pyside qt4 tk wxwidgets
90 || ( gtk gtk3 )
91 )"
92
93RESTRICT="mirror"
94
95# A few C++ source files are written to srcdir.
96# Other than that, the ebuild shall be fit for out-of-source build.
97DISTUTILS_IN_SOURCE_BUILD=1
98
99use_setup() {
100 local uword="${2:-${1}}"
101 if use ${1}; then
102 echo "${uword} = True"
103 echo "${uword}agg = True"
104 else
105 echo "${uword} = False"
106 echo "${uword}agg = False"
107 fi
108}
109
110python_prepare_all() {
111# Generates test failures, but fedora does it
112# local PATCHES=(
113# "${FILESDIR}"/${P}-unbundle-pycxx.patch
114# "${FILESDIR}"/${P}-unbundle-agg.patch
115# )
116# rm -r agg24 CXX || die
117# rm -r agg24 || die
118
119 sed -i \
120 -e "s:\<pkg-config\>:$(tc-getPKG_CONFIG):" \
121 setupext.py || die
122 epatch "${FILESDIR}"/${P}-cross-compile.patch
123
124 sed \
125 -e 's/matplotlib.pyparsing_py[23]/pyparsing/g' \
126 -i lib/matplotlib/{mathtext,fontconfig_pattern}.py \
127 || die "sed pyparsing failed"
128
129 # suggested by upstream
130 sed \
131 -e '/tol/s:32:35:g' \
132 -i lib/matplotlib/tests/test_mathtext.py || die
133
134 if use gtk || use gtk3; then
135 export XDG_RUNTIME_DIR="${T}/runtime-dir"
136 mkdir "${XDG_RUNTIME_DIR}" || die
137 chmod 0700 "${XDG_RUNTIME_DIR}" || die
138 fi
139
140 distutils-r1_python_prepare_all
141}
142
143python_configure_all() {
144 append-flags -fno-strict-aliasing
145}
146
147python_configure() {
148 mkdir -p "${BUILD_DIR}" || die
149
150 # create setup.cfg (see setup.cfg.template for any changes).
151
152 # common switches.
153 cat > "${BUILD_DIR}"/setup.cfg <<-EOF
154 [directories]
155 basedirlist = ${EPREFIX}/usr
156 [provide_packages]
157 pytz = False
158 dateutil = False
159 [gui_support]
160 agg = True
161 $(use_setup cairo)
162 $(use_setup pyside)
163 $(use_setup qt4)
164 $(use_setup tk)
165 EOF
166
167 if use gtk3 && use cairo; then
168 echo "gtk3cairo = True" >> "${BUILD_DIR}"/setup.cfg || die
169 else
170 echo "gtk3cairo = False" >> "${BUILD_DIR}"/setup.cfg || die
171 fi
172
173 if $(python_is_python3); then
174 cat >> "${BUILD_DIR}"/setup.cfg <<-EOF
175 six = True
176 fltk = False
177 fltkagg = False
178 gtk = False
179 gtkagg = False
180 wx = False
181 wxagg = False
182 EOF
183 else
184 cat >> "${BUILD_DIR}"/setup.cfg <<-EOF
185 six = False
186 $(use_setup fltk)
187 $(use_setup gtk)
188 $(use_setup gtk3)
189 $(use_setup wxwidgets wx)
190 EOF
191 fi
192}
193
194wrap_setup() {
195 local MPLSETUPCFG=${BUILD_DIR}/setup.cfg
196 export MPLSETUPCFG
197
198 # Note: remove build... if switching to out-of-source build
199 "${@}" build --build-lib="${BUILD_DIR}"/build/lib
200}
201
202python_compile() {
203 VIRTUALX_COMMAND="wrap_setup distutils-r1_python_compile"
204 virtualmake
205}
206
207python_compile_all() {
208 if use doc; then
209 cd doc || die
210
211 # necessary for in-source build
212 local -x PYTHONPATH="${BUILD_DIR}"/build/lib:${PYTHONPATH}
213
214 unset DISPLAY # bug #278524
215 VARTEXFONTS="${T}"/fonts \
216 "${PYTHON}" ./make.py --small html || die
217 fi
218}
219
220python_test() {
221 wrap_setup distutils_install_for_testing
222
223 cd "${TMPDIR}" || die
224 VIRTUALX_COMMAND="${PYTHON}"
225 virtualmake -c "import sys, matplotlib as m; sys.exit(0 if m.test(verbosity=2) else 1)" || \
226 die "Tests fail with ${EPYTHON}"
227}
228
229python_install() {
230 wrap_setup distutils-r1_python_install
231}
232
233python_install_all() {
234 use doc && local HTML_DOCS=( doc/build/html/. )
235
236 distutils-r1_python_install_all
237
238 if use examples; then
239 dodoc -r examples
240 docompress -x /usr/share/doc/${PF}/examples
241 fi
242}