Advertisement
yellowhat

matplotlib-9999.ebuild

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