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

Contents of /eclass/twisted.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Fri Oct 30 13:14:17 2009 UTC (4 years, 11 months ago) by arfrever
Branch: MAIN
Changes since 1.6: +60 -46 lines
Support installation for multiple versions of Python.

1 # Copyright 2005 Gentoo Foundation
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.6 2006/05/29 18:46:08 marienz Exp $
4 #
5 # Author: Marien Zwart <marienz@gentoo.org>
6 #
7 # eclass to aid installing and testing twisted packages.
8 #
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).
11 #
12 # twisted_src_test relies on the package installing twisted.names to
13 # have a ${PN} of twisted-names.
14
15 inherit distutils eutils versionator
16
17 MY_PV="${MY_PV:-${PV}}"
18 MY_VERSION="$(get_version_component_range 1-2 ${MY_PV})"
19 MY_P="Twisted${MY_PACKAGE}-${MY_PV}"
20
21 HOMEPAGE="http://www.twistedmatrix.com/"
22 SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/${MY_VERSION}/${MY_P}.tar.bz2"
23
24 LICENSE="MIT"
25 SLOT="0"
26 IUSE=""
27
28 S="${WORKDIR}/${MY_P}"
29
30 twisted_src_test() {
31 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
32 testing() {
33 # This is a hack to make tests work without installing to the live
34 # filesystem. We copy the twisted site-packages to a temporary
35 # dir, install there, and run from there.
36 local spath="$(python_get_sitedir)"
37 mkdir -p "${T}/${spath}"
38 cp -R "${ROOT}${spath}/twisted" "${T}/${spath}" || die "Copying of files failed with Python ${PYTHON_ABI}"
39
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
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
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}"
75 fi
76 }
77
78 twisted_src_install() {
79 distutils_src_install
80
81 if [[ -d doc/man ]]; then
82 doman doc/man/*
83 fi
84
85 if [[ -d doc ]]; then
86 insinto /usr/share/doc/${PF}
87 doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man)
88 fi
89 }
90
91 update_plugin_cache() {
92 einfo "Updating twisted plugin cache..."
93 # we have to remove the cache or removed plugins won't be removed
94 # from the cache (http://twistedmatrix.com/bugs/issue926)
95 rm "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache"
96 # notice we have to use getPlugIns here for <=twisted-2.0.1 compatibility
97 python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))"
98 }
99
100 twisted_pkg_postrm() {
101 distutils_pkg_postrm
102 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
103 python_execute_function update_plugin_cache
104 else
105 update_plugin_cache
106 fi
107 }
108
109 twisted_pkg_postinst() {
110 distutils_pkg_postinst
111 if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then
112 python_execute_function update_plugin_cache
113 else
114 update_plugin_cache
115 fi
116 }
117
118 EXPORT_FUNCTIONS src_test src_install pkg_postrm pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20