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

Contents of /eclass/twisted.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Sun Oct 10 19:39:49 2010 UTC (3 years, 9 months ago) by arfrever
Branch: MAIN
Changes since 1.7: +110 -90 lines
Update comments.
Don't inherit unused eutils.eclass.
Don't export twisted_src_test() for packages other than dev-python/twisted*.
Delete needless MY_VERSION variable.
Set some variables only for dev-python/twisted*.
Delete support for <=dev-python/twisted*-8.2.0.
Clean and improve twisted_src_test().
Support TWISTED_PLUGINS variable in twisted_pkg_postinst() and twisted_pkg_postrm() (bug #258698).
Ignore ImportErrors in twisted_pkg_postrm() (bug #327111).
Create dropin.cache files in EROOT directory.
Delete empty directories and all dropin.cache files in twisted_pkg_postrm().
Ignore missing Python interpreter in twisted_pkg_postrm().

1 # Copyright 2005-2010 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.7 2009/10/30 13:14:17 arfrever Exp $
4
5 # @ECLASS: twisted.eclass
6 # @MAINTAINER:
7 # Gentoo Python Project <python@gentoo.org>
8 # @BLURB: Eclass for Twisted packages
9 # @DESCRIPTION:
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)
15
16 inherit distutils versionator
17
18 EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
19
20 if [[ "${CATEGORY}/${PN}" == "dev-python/twisted"* ]]; then
21 EXPORT_FUNCTIONS src_test
22
23 MY_PV="${MY_PV:-${PV}}"
24 MY_P="Twisted${MY_PACKAGE}-${MY_PV}"
25
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
29 LICENSE="MIT"
30 SLOT="0"
31 IUSE=""
32
33 S="${WORKDIR}/${MY_P}"
34
35 TWISTED_PLUGINS="${TWISTED_PLUGINS:-twisted.plugins}"
36 fi
37
38 # @ECLASS-VARIABLE: TWISTED_PLUGINS
39 # @DESCRIPTION:
40 # Twisted plugins, whose cache is regenerated in pkg_postinst() and pkg_postrm() phases.
41
42 twisted_src_test() {
43 if [[ "${CATEGORY}/${PN}" != "dev-python/twisted"* ]]; then
44 die "${FUNCNAME}() can be used only in dev-python/twisted* packages"
45 fi
46
47 testing() {
48 local sitedir="${EPREFIX}$(python_get_sitedir)"
49
50 # Copy modules of other Twisted packages from site-packages directory to temporary directory.
51 mkdir -p "${T}/${sitedir}"
52 cp -R "${ROOT}${sitedir}/twisted" "${T}/${sitedir}" || die "Copying of modules of other Twisted packages failed with $(python_get_implementation) $(python_get_version)"
53 rm -fr "${T}/${sitedir}/${PN/-//}"
54
55 # Install modules of current package to temporary directory.
56 "$(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)"
57
58 pushd "${T}/${sitedir}" > /dev/null || return 1
59 PATH="${T}${EPREFIX}/usr/bin:${PATH}" PYTHONPATH="${T}/${sitedir}" trial ${PN/-/.} || return 1
60 popd > /dev/null || return 1
61
62 rm -fr "${T}/${sitedir}"
63 }
64 python_execute_function testing
65 }
66
67 twisted_src_install() {
68 distutils_src_install
69
70 if [[ -d doc/man ]]; then
71 doman doc/man/*
72 fi
73
74 if [[ -d doc ]]; then
75 insinto /usr/share/doc/${PF}
76 doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man)
77 fi
78 }
79
80 _twisted_update_plugin_cache() {
81 local dir exit_status="0" module
82
83 for module in ${TWISTED_PLUGINS}; do
84 if [[ -d "${EROOT}$(python_get_sitedir -b)/${module//.//}" ]]; then
85 find "${EROOT}$(python_get_sitedir -b)/${module//.//}" -name dropin.cache -print0 | xargs -0 rm -f
86 fi
87 done
88
89 if [[ -n "$(type -p "$(PYTHON)")" ]]; then
90 for module in ${TWISTED_PLUGINS}; do
91 # http://twistedmatrix.com/documents/current/core/howto/plugin.html
92 "$(PYTHON)" -c \
93 "import sys
94 sys.path.insert(0, '${EROOT}$(python_get_sitedir -b)')
95
96 try:
97 import twisted.plugin
98 import ${module}
99 except ImportError:
100 if '${EBUILD_PHASE}' == 'postinst':
101 raise
102 else:
103 # Twisted, zope.interface or given plugins might have been uninstalled.
104 sys.exit(0)
105
106 list(twisted.plugin.getPlugins(twisted.plugin.IPlugin, ${module}))" || exit_status="1"
107 done
108 fi
109
110 for module in ${TWISTED_PLUGINS}; do
111 # Delete empty parent directories.
112 local dir="${EROOT}$(python_get_sitedir -b)/${module//.//}"
113 while [[ "${dir}" != "${EROOT%/}" ]]; do
114 rmdir "${dir}" 2> /dev/null || break
115 dir="${dir%/*}"
116 done
117 done
118
119 return "${exit_status}"
120 }
121
122 twisted_pkg_postinst() {
123 distutils_pkg_postinst
124 python_execute_function \
125 --action-message 'Regeneration of Twisted plugin cache with $(python_get_implementation) $(python_get_version)' \
126 --failure-message 'Regeneration of Twisted plugin cache failed with $(python_get_implementation) $(python_get_version)' \
127 --nonfatal \
128 _twisted_update_plugin_cache
129 }
130
131 twisted_pkg_postrm() {
132 distutils_pkg_postrm
133 python_execute_function \
134 --action-message 'Regeneration of Twisted plugin cache with $(python_get_implementation) $(python_get_version)' \
135 --failure-message 'Regeneration of Twisted plugin cache failed with $(python_get_implementation) $(python_get_version)' \
136 --nonfatal \
137 _twisted_update_plugin_cache
138 }

  ViewVC Help
Powered by ViewVC 1.1.20