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

Contents of /eclass/twisted.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Tue Dec 27 06:54:23 2011 UTC (2 years, 11 months ago) by floppym
Branch: MAIN
Changes since 1.9: +2 -2 lines
Only call doman on manpages in twisted_src_install. Credit to Arfrever.

1 # Copyright 1999-2011 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.9 2011/12/27 05:36:48 floppym 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 SRC_URI="http://twistedmatrix.com/Releases/${MY_PACKAGE}/$(get_version_component_range 1-2 ${MY_PV})/${MY_P}.tar.bz2"
29
30 LICENSE="MIT"
31 SLOT="0"
32 IUSE=""
33
34 S="${WORKDIR}/${MY_P}"
35
36 TWISTED_PLUGINS="${TWISTED_PLUGINS:-twisted.plugins}"
37 fi
38
39 # @ECLASS-VARIABLE: TWISTED_PLUGINS
40 # @DESCRIPTION:
41 # Twisted plugins, whose cache is regenerated in pkg_postinst() and pkg_postrm() phases.
42
43 twisted_src_test() {
44 if [[ "${CATEGORY}/${PN}" != "dev-python/twisted"* ]]; then
45 die "${FUNCNAME}() can be used only in dev-python/twisted* packages"
46 fi
47
48 testing() {
49 local sitedir="${EPREFIX}$(python_get_sitedir)"
50
51 # Copy modules of other Twisted packages from site-packages directory to temporary directory.
52 mkdir -p "${T}/${sitedir}"
53 cp -R "${ROOT}${sitedir}/twisted" "${T}/${sitedir}" || die "Copying of modules of other Twisted packages failed with $(python_get_implementation) $(python_get_version)"
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
63 rm -fr "${T}/${sitedir}"
64 }
65 python_execute_function testing
66 }
67
68 twisted_src_install() {
69 distutils_src_install
70
71 if [[ -d doc/man ]]; then
72 doman doc/man/*.[[:digit:]]
73 fi
74
75 if [[ -d doc ]]; then
76 insinto /usr/share/doc/${PF}
77 doins -r $(find doc -mindepth 1 -maxdepth 1 -not -name man)
78 fi
79 }
80
81 _twisted_update_plugin_cache() {
82 local dir exit_status="0" module
83
84 for module in ${TWISTED_PLUGINS}; do
85 if [[ -d "${EROOT}$(python_get_sitedir -b)/${module//.//}" ]]; then
86 find "${EROOT}$(python_get_sitedir -b)/${module//.//}" -name dropin.cache -print0 | xargs -0 rm -f
87 fi
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
95 sys.path.insert(0, '${EROOT}$(python_get_sitedir -b)')
96
97 try:
98 import twisted.plugin
99 import ${module}
100 except 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
107 list(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
123 twisted_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
130 }
131
132 twisted_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 \
138 _twisted_update_plugin_cache
139 }

  ViewVC Help
Powered by ViewVC 1.1.20