/[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.9
1# Copyright 2005 Gentoo Foundation 1# Copyright 1999-2011 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.9 2011/12/27 05:36:48 floppym Exp $
4# 4
5# Author: Marien Zwart <marienz@gentoo.org> 5# @ECLASS: twisted.eclass
6# 6# @MAINTAINER:
7# eclass to aid installing and testing twisted packages. 7# Gentoo Python Project <python@gentoo.org>
8# 8# @BLURB: Eclass for Twisted packages
9# you should set MY_PACKAGE to something like 'Names' before inheriting. 9# @DESCRIPTION:
10# you may set MY_PV to the right version (defaults to PV). 10# The twisted eclass defines phase functions for Twisted packages.
11
12# The following variables can be set in dev-python/twisted* packages before inheriting this eclass:
13# MY_PACKAGE - Package name suffix (required)
14# MY_PV - Package version (optional)
11 15
12inherit distutils versionator 16inherit distutils versionator
13 17
14MY_PV=${MY_PV:-${PV}} 18EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
15MY_VERSION=$(get_version_component_range 1-2 ${MY_PV})
16MY_P=Twisted${MY_PACKAGE}-${MY_PV}
17 19
18HOMEPAGE="http://www.twistedmatrix.com/" 20if [[ "${CATEGORY}/${PN}" == "dev-python/twisted"* ]]; then
19SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/${MY_VERSION}/${MY_P}.tar.bz2" 21 EXPORT_FUNCTIONS src_test
20 22
21LICENSE="MIT" 23 MY_PV="${MY_PV:-${PV}}"
22SLOT="0" 24 MY_P="Twisted${MY_PACKAGE}-${MY_PV}"
23 25
24IUSE="" 26 HOMEPAGE="http://www.twistedmatrix.com/"
27 #SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/$(get_version_component_range 1-2 ${MY_PV})/${MY_P}.tar.bz2"
28 SRC_URI="http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range 1-2 ${MY_PV})/${MY_P}.tar.bz2"
25 29
30 LICENSE="MIT"
31 SLOT="0"
32 IUSE=""
33
26S="${WORKDIR}/${MY_P}" 34 S="${WORKDIR}/${MY_P}"
35
36 TWISTED_PLUGINS="${TWISTED_PLUGINS:-twisted.plugins}"
37fi
38
39# @ECLASS-VARIABLE: TWISTED_PLUGINS
40# @DESCRIPTION:
41# Twisted plugins, whose cache is regenerated in pkg_postinst() and pkg_postrm() phases.
27 42
28twisted_src_test() { 43twisted_src_test() {
29 python_version 44 if [[ "${CATEGORY}/${PN}" != "dev-python/twisted"* ]]; then
30 # This is a hack to make tests work without installing to the live 45 die "${FUNCNAME}() can be used only in dev-python/twisted* packages"
31 # filesystem. We copy the twisted site-packages to a temporary
32 # dir, install there, and run from there.
33 local spath="usr/lib/python${PYVER}/site-packages/"
34 mkdir -p "${T}/${spath}"
35 cp -R "${ROOT}${spath}/twisted" "${T}/${spath}" || die
36 if has_version ">=dev-lang/python-2.3"; then
37 ${python} setup.py install --root="${T}" --no-compile --force || die
38 else
39 ${python} setup.py install --root="${T}" --force || die
40 fi 46 fi
41 cd "${T}/${spath}" || die 47
42 local trialopts 48 testing() {
43 if ! has_version ">=dev-python/twisted-2.2"; then 49 local sitedir="${EPREFIX}$(python_get_sitedir)"
44 trialopts=-R 50
45 fi 51 # Copy modules of other Twisted packages from site-packages directory to temporary directory.
46 PATH="${T}/usr/bin:${PATH}" PYTHONPATH="${T}/${spath}" \ 52 mkdir -p "${T}/${sitedir}"
47 trial ${trialopts} ${PN/-/.} || die "trial failed" 53 cp -R "${ROOT}${sitedir}/twisted" "${T}/${sitedir}" || die "Copying of modules of other Twisted packages failed with $(python_get_implementation) $(python_get_version)"
48 cd "${S}" 54 rm -fr "${T}/${sitedir}/${PN/-//}"
55
56 # Install modules of current package to temporary directory.
57 "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --force --no-compile --root="${T}" || die "Installation into temporary directory failed with $(python_get_implementation) $(python_get_version)"
58
59 pushd "${T}/${sitedir}" > /dev/null || return 1
60 PATH="${T}${EPREFIX}/usr/bin:${PATH}" PYTHONPATH="${T}/${sitedir}" trial ${PN/-/.} || return 1
61 popd > /dev/null || return 1
62
49 rm -rf "${T}/${spath}" 63 rm -fr "${T}/${sitedir}"
64 }
65 python_execute_function testing
50} 66}
51 67
52twisted_src_install() { 68twisted_src_install() {
53 distutils_src_install 69 distutils_src_install
54 70
60 insinto /usr/share/doc/${PF} 76 insinto /usr/share/doc/${PF}
61 doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man) 77 doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man)
62 fi 78 fi
63} 79}
64 80
65update_plugin_cache() { 81_twisted_update_plugin_cache() {
66 einfo "Updating twisted plugin cache..." 82 local dir exit_status="0" module
67 python_version 83
68 # we have to remove the cache or removed plugins won't be removed 84 for module in ${TWISTED_PLUGINS}; do
69 # from the cache (http://twistedmatrix.com/bugs/issue926) 85 if [[ -d "${EROOT}$(python_get_sitedir -b)/${module//.//}" ]]; then
70 rm "${ROOT}usr/$(get_libdir)/python${PYVER}/site-packages/twisted/plugins/dropin.cache" 86 find "${EROOT}$(python_get_sitedir -b)/${module//.//}" -name dropin.cache -print0 | xargs -0 rm -f
71 # notice we have to use getPlugIns here for <=twisted-2.0.1 compatibility 87 fi
72 python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))" 88 done
89
90 if [[ -n "$(type -p "$(PYTHON)")" ]]; then
91 for module in ${TWISTED_PLUGINS}; do
92 # http://twistedmatrix.com/documents/current/core/howto/plugin.html
93 "$(PYTHON)" -c \
94"import sys
95sys.path.insert(0, '${EROOT}$(python_get_sitedir -b)')
96
97try:
98 import twisted.plugin
99 import ${module}
100except ImportError:
101 if '${EBUILD_PHASE}' == 'postinst':
102 raise
103 else:
104 # Twisted, zope.interface or given plugins might have been uninstalled.
105 sys.exit(0)
106
107list(twisted.plugin.getPlugins(twisted.plugin.IPlugin, ${module}))" || exit_status="1"
108 done
109 fi
110
111 for module in ${TWISTED_PLUGINS}; do
112 # Delete empty parent directories.
113 local dir="${EROOT}$(python_get_sitedir -b)/${module//.//}"
114 while [[ "${dir}" != "${EROOT%/}" ]]; do
115 rmdir "${dir}" 2> /dev/null || break
116 dir="${dir%/*}"
117 done
118 done
119
120 return "${exit_status}"
121}
122
123twisted_pkg_postinst() {
124 distutils_pkg_postinst
125 python_execute_function \
126 --action-message 'Regeneration of Twisted plugin cache with $(python_get_implementation) $(python_get_version)' \
127 --failure-message 'Regeneration of Twisted plugin cache failed with $(python_get_implementation) $(python_get_version)' \
128 --nonfatal \
129 _twisted_update_plugin_cache
73} 130}
74 131
75twisted_pkg_postrm() { 132twisted_pkg_postrm() {
76 distutils_pkg_postrm 133 distutils_pkg_postrm
134 python_execute_function \
135 --action-message 'Regeneration of Twisted plugin cache with $(python_get_implementation) $(python_get_version)' \
136 --failure-message 'Regeneration of Twisted plugin cache failed with $(python_get_implementation) $(python_get_version)' \
137 --nonfatal \
77 update_plugin_cache 138 _twisted_update_plugin_cache
78} 139}
79
80twisted_pkg_postinst() {
81 distutils_pkg_postinst
82 update_plugin_cache
83}
84
85EXPORT_FUNCTIONS src_test src_install pkg_postrm pkg_postinst

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

  ViewVC Help
Powered by ViewVC 1.1.20