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