/[gentoo-x86]/eclass/twisted.eclass
Gentoo

Diff of /eclass/twisted.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.4 Revision 1.7
1# Copyright 2005 Gentoo Foundation 1# Copyright 2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License, v2 or later 2# Distributed under the terms of the GNU General Public License, v2 or later
3# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.4 2006/04/09 23:18:36 marienz Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.7 2009/10/30 13:14:17 arfrever Exp $
4# 4#
5# Author: Marien Zwart <marienz@gentoo.org> 5# Author: Marien Zwart <marienz@gentoo.org>
6# 6#
7# eclass to aid installing and testing twisted packages. 7# eclass to aid installing and testing twisted packages.
8# 8#
9# you should set MY_PACKAGE to something like 'Names' before inheriting. 9# you should set MY_PACKAGE to something like 'Names' before inheriting.
10# you may set MY_PV to the right version (defaults to PV). 10# you may set MY_PV to the right version (defaults to PV).
11#
12# twisted_src_test relies on the package installing twisted.names to
13# have a ${PN} of twisted-names.
11 14
12inherit distutils versionator 15inherit distutils eutils versionator
13 16
14MY_PV=${MY_PV:-${PV}} 17MY_PV="${MY_PV:-${PV}}"
15MY_VERSION=$(get_version_component_range 1-2 ${MY_PV}) 18MY_VERSION="$(get_version_component_range 1-2 ${MY_PV})"
16MY_P=Twisted${MY_PACKAGE}-${MY_PV} 19MY_P="Twisted${MY_PACKAGE}-${MY_PV}"
17 20
18HOMEPAGE="http://www.twistedmatrix.com/" 21HOMEPAGE="http://www.twistedmatrix.com/"
19SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/${MY_VERSION}/${MY_P}.tar.bz2" 22SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/${MY_VERSION}/${MY_P}.tar.bz2"
20 23
21LICENSE="MIT" 24LICENSE="MIT"
22SLOT="0" 25SLOT="0"
23
24IUSE="" 26IUSE=""
25 27
26S="${WORKDIR}/${MY_P}" 28S="${WORKDIR}/${MY_P}"
27 29
28twisted_src_test() { 30twisted_src_test() {
29 python_version 31 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
32 testing() {
30 # This is a hack to make tests work without installing to the live 33 # This is a hack to make tests work without installing to the live
31 # filesystem. We copy the twisted site-packages to a temporary 34 # filesystem. We copy the twisted site-packages to a temporary
32 # dir, install there, and run from there. 35 # dir, install there, and run from there.
33 local spath="usr/lib/python${PYVER}/site-packages/" 36 local spath="$(python_get_sitedir)"
34 mkdir -p "${T}/${spath}" 37 mkdir -p "${T}/${spath}"
35 cp -R "${ROOT}${spath}/twisted" "${T}/${spath}" || die 38 cp -R "${ROOT}${spath}/twisted" "${T}/${spath}" || die "Copying of files failed with Python ${PYTHON_ABI}"
36 if has_version ">=dev-lang/python-2.3"; then 39
37 ${python} setup.py install --root="${T}" --no-compile --force || die 40 # We have to get rid of the existing version of this package
41 # instead of just installing on top of it, since if the existing
42 # package has tests in files the version we are installing does
43 # not have we end up running e.g. twisted-names-0.3.0 tests when
44 # downgrading to twisted-names-0.1.0-r1.
45 rm -fr "${T}/${spath}/${PN/-//}"
46
47 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --root="${T}" --no-compile --force || die "Installation for tests failed with Python ${PYTHON_ABI}"
48 cd "${T}/${spath}" || die
49 PATH="${T}/usr/bin:${PATH}" PYTHONPATH="${T}/${spath}" trial ${PN/-/.} || die "trial failed with Python ${PYTHON_ABI}"
50 cd "${S}"
51 rm -fr "${T}/${spath}"
52 }
53 python_execute_function testing
38 else 54 else
55 # This is a hack to make tests work without installing to the live
56 # filesystem. We copy the twisted site-packages to a temporary
57 # dir, install there, and run from there.
58 local spath="$(python_get_sitedir)"
59 mkdir -p "${T}/${spath}"
60 cp -R "${ROOT}${spath}/twisted" "${T}/${spath}" || die
61
62 # We have to get rid of the existing version of this package
63 # instead of just installing on top of it, since if the existing
64 # package has tests in files the version we are installing does
65 # not have we end up running fex twisted-names-0.3.0 tests when
66 # downgrading to twisted-names-0.1.0-r1.
67 rm -rf "${T}/${spath}/${PN/-//}"
68
39 ${python} setup.py install --root="${T}" --force || die 69 "${python}" setup.py install --root="${T}" --no-compile --force || die
70 cd "${T}/${spath}" || die
71 PATH="${T}/usr/bin:${PATH}" PYTHONPATH="${T}/${spath}" \
72 trial ${PN/-/.} || die "trial failed"
73 cd "${S}"
74 rm -rf "${T}/${spath}"
40 fi 75 fi
41 cd "${T}/${spath}" || die
42 local trialopts
43 if ! has_version ">=dev-python/twisted-2.2"; then
44 trialopts=-R
45 fi
46 PATH="${T}/usr/bin:${PATH}" PYTHONPATH="${T}/${spath}" \
47 trial ${trialopts} ${PN/-/.} || die "trial failed"
48 cd "${S}"
49 rm -rf "${T}/${spath}"
50} 76}
51 77
52twisted_src_install() { 78twisted_src_install() {
53 distutils_src_install 79 distutils_src_install
54 80
62 fi 88 fi
63} 89}
64 90
65update_plugin_cache() { 91update_plugin_cache() {
66 einfo "Updating twisted plugin cache..." 92 einfo "Updating twisted plugin cache..."
67 python_version
68 # we have to remove the cache or removed plugins won't be removed 93 # we have to remove the cache or removed plugins won't be removed
69 # from the cache (http://twistedmatrix.com/bugs/issue926) 94 # from the cache (http://twistedmatrix.com/bugs/issue926)
70 rm "${ROOT}usr/$(get_libdir)/python${PYVER}/site-packages/twisted/plugins/dropin.cache" 95 rm "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache"
71 # notice we have to use getPlugIns here for <=twisted-2.0.1 compatibility 96 # notice we have to use getPlugIns here for <=twisted-2.0.1 compatibility
72 python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))" 97 python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))"
73} 98}
74 99
75twisted_pkg_postrm() { 100twisted_pkg_postrm() {
76 distutils_pkg_postrm 101 distutils_pkg_postrm
102 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
103 python_execute_function update_plugin_cache
104 else
77 update_plugin_cache 105 update_plugin_cache
106 fi
78} 107}
79 108
80twisted_pkg_postinst() { 109twisted_pkg_postinst() {
81 distutils_pkg_postinst 110 distutils_pkg_postinst
111 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
112 python_execute_function update_plugin_cache
113 else
82 update_plugin_cache 114 update_plugin_cache
115 fi
83} 116}
84 117
85EXPORT_FUNCTIONS src_test src_install pkg_postrm pkg_postinst 118EXPORT_FUNCTIONS src_test src_install pkg_postrm pkg_postinst

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.20