1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/matplotlib/matplotlib-1.1.0.ebuild,v 1.11 2012/02/27 16:05:59 ranger Exp $
EAPI="3"
PYTHON_DEPEND="2"
PYTHON_USE_WITH="tk"
PYTHON_USE_WITH_OPT="tk"
SUPPORT_PYTHON_ABIS="1"
RESTRICT_PYTHON_ABIS="3.* *-jython 2.7-pypy-*"
WX_GTK_VER="2.8"
inherit distutils
DESCRIPTION="Pure python plotting library with matlab like syntax"
HOMEPAGE="http://matplotlib.sourceforge.net/ http://pypi.python.org/pypi/matplotlib"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz
doc? ( mirror://sourceforge/${PN}/mpl_sampledata-${PV}.tar.gz )
examples? ( mirror://sourceforge/${PN}/mpl_sampledata-${PV}.tar.gz )"
IUSE="cairo doc excel examples fltk gtk latex qt4 tk wxwidgets"
SLOT="0"
KEYWORDS="amd64 ppc ~ppc64 x86 ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
# Main license: matplotlib
# Some modules: BSD
# matplotlib/backends/qt4_editor: MIT
# Fonts: BitstreamVera, OFL-1.1
LICENSE="BitstreamVera BSD matplotlib MIT OFL-1.1"
CDEPEND="dev-python/numpy
dev-python/python-dateutil:python-2
dev-python/pytz
media-libs/freetype:2
media-libs/libpng
gtk? ( dev-python/pygtk )
wxwidgets? ( dev-python/wxpython:2.8 )"
DEPEND="${CDEPEND}
dev-python/pycxx
dev-util/pkgconfig
doc? (
app-text/dvipng
dev-python/imaging
dev-python/ipython
dev-python/xlwt
dev-python/sphinx
media-gfx/graphviz[cairo]
dev-texlive/texlive-latexextra
dev-texlive/texlive-fontsrecommended
dev-texlive/texlive-latexrecommended
)"
RDEPEND="${CDEPEND}
virtual/ttf-fonts
media-fonts/stix-fonts
media-fonts/texcm-ttf
dev-python/pyparsing
cairo? ( dev-python/pycairo )
excel? ( dev-python/xlwt )
fltk? ( dev-python/pyfltk )
qt4? ( || ( dev-python/PyQt4[X] dev-python/pyside[X] ) )
latex? (
virtual/latex-base
app-text/ghostscript-gpl
app-text/dvipng
app-text/poppler[utils]
dev-texlive/texlive-fontsrecommended
)"
PYTHON_CFLAGS=("2.* + -fno-strict-aliasing")
PYTHON_CXXFLAGS=("2.* + -fno-strict-aliasing")
PYTHON_MODNAME="matplotlib mpl_toolkits pylab.py"
use_setup() {
local uword="${2:-${1}}"
if use ${1}; then
echo "${uword} = True"
echo "${uword}agg = True"
else
echo "${uword} = False"
echo "${uword}agg = False"
fi
}
src_prepare() {
# create setup.cfg (see setup.cfg.template for any changes)
cat > setup.cfg <<-EOF
[provide_packages]
pytz = False
dateutil = False
[gui_support]
$(use_setup cairo)
$(use_setup fltk)
$(use_setup gtk)
$(use_setup qt4)
$(use_setup tk)
$(use_setup wxwidgets wx)
EOF
# avoid checks needing a X display
sed -i \
-e "s/check_for_gtk()/$(use gtk && echo True || echo False)/" \
-e "s/check_for_tk()/$(use tk && echo True || echo False)/" \
setup.py || die "sed setup.py failed"
# respect FHS:
# - mpl-data in /usr/share/matplotlib
# - config files in /etc/matplotlib
sed -i \
-e "/'mpl-data\/matplotlibrc',/d" \
-e "/'mpl-data\/matplotlib.conf',/d" \
-e "s:'lib/matplotlib/mpl-data/matplotlibrc':'matplotlibrc':" \
-e "s:'lib/matplotlib/mpl-data/matplotlib.conf':'matplotlib.conf':" \
setup.py || die "sed setup.py for FHS failed"
# remove internal copies of pycxx, pyparsing
rm -rf CXX lib/matplotlib/pyparsing.py \
|| die "removed internal copies failed"
# bug #334429 https://developer.mozilla.org/en/Mozilla_MathML_Project/Fonts
# which advise against bakoma fonts
sed -i \
-e '/fontset/s/cm/stix/' \
lib/matplotlib/mpl-data/matplotlib.conf* || die
sed -i \
-e 's/matplotlib.pyparsing/pyparsing/g' \
lib/matplotlib/{mathtext,fontconfig_pattern}.py \
|| die "sed pyparsing failed"
# some fixes to avoid fetching data while compiling examples in tests
if use doc || use examples; then
cat <<-EOF >> doc/matplotlibrc
examples.download : False
examples.directory : ${WORKDIR}/mpl_sampledata-${PV}
EOF
cat <<-EOF >> matplotlibrc.template
examples.download : False
examples.directory : ${EPREFIX}/usr/share/${PF}/examples
EOF
fi
}
src_compile() {
unset DISPLAY # bug #278524
distutils_src_compile_pre_hook() {
ln -fs "${EPREFIX}/usr/share/python$(python_get_version)/CXX" .
}
distutils_src_compile
if use doc; then
cd "${S}/doc"
MATPLOTLIBDATA="${S}/lib/matplotlib/mpl-data" \
VARTEXFONTS="${T}"/fonts \
PYTHONPATH=$(ls -d "${S}"/build-$(PYTHON -f --ABI)/lib*) \
"$(PYTHON -f)" make.py --small all
[[ -e build/latex/Matplotlib.pdf ]] || die "doc generation failed"
fi
}
src_test() {
# if doc were enabled, all examples were built and tested
use doc && return
einfo "Tests are quite long, be patient"
cd "${S}/examples/tests"
testing() {
PYTHONPATH=$(ls -d "${S}"/build-${PYTHON_ABI}/lib*) \
"$(PYTHON)" backend_driver.py agg || return 1
PYTHONPATH=$(ls -d "${S}"/build-${PYTHON_ABI}/lib*) \
"$(PYTHON)" backend_driver.py --clean
}
python_execute_function testing
}
src_install() {
# remove fonts bundles except some computer modern ones
rm -f lib/matplotlib/mpl-data/fonts/ttf/cm{ex,mi,r,sy}10.ttf || die
rm -f lib/matplotlib/mpl-data/fonts/ttf/{Vera*,*.TXT} || die
rm -rf lib/matplotlib/mpl-data/fonts/{afm,pdfcorefonts} || die
# sed only after doc building, to allow using default configs
sed -i \
-e "s:path = get_data_path():path = '${EPREFIX}/etc/matplotlib':" \
-e "s:os.path.dirname(__file__):'${EPREFIX}/usr/share/${PN}':g" \
build-*/lib*/matplotlib/__init__.py \
|| die "sed init for FHS failed"
distutils_src_install
# respect FHS
dodir /usr/share/${PN}
mv "${ED}$(python_get_sitedir -f)/${PN}/"{mpl-data,backends/Matplotlib.nib} \
"${ED}usr/share/${PN}" || die "Renaming failed"
rm -fr "${ED}"usr/lib*/*/site-packages/${PN}/{mpl-data,backends/Matplotlib.nib}
insinto /etc/matplotlib
doins matplotlibrc matplotlib.conf
# doc and examples
if use doc; then
insinto /usr/share/doc/${PF}
doins -r doc/build/latex/Matplotlib.pdf doc/build/html || die
fi
if use examples; then
insinto /usr/share/doc/${PF}/examples
doins -r "${WORKDIR}"/mpl_sampledata-${PV}/* || die
fi
}
|