| 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.6 2006/05/29 18:46:08 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 | # |
| … | |
… | |
| 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 | # |
11 | # |
| 12 | # twisted_src_test relies on the package installing twisted.names to |
12 | # twisted_src_test relies on the package installing twisted.names to |
| 13 | # have a ${PN} of twisted-names. |
13 | # have a ${PN} of twisted-names. |
| 14 | |
14 | |
| 15 | inherit distutils versionator eutils |
15 | inherit distutils eutils versionator |
| 16 | |
16 | |
| 17 | MY_PV=${MY_PV:-${PV}} |
17 | MY_PV="${MY_PV:-${PV}}" |
| 18 | MY_VERSION=$(get_version_component_range 1-2 ${MY_PV}) |
18 | MY_VERSION="$(get_version_component_range 1-2 ${MY_PV})" |
| 19 | MY_P=Twisted${MY_PACKAGE}-${MY_PV} |
19 | MY_P="Twisted${MY_PACKAGE}-${MY_PV}" |
| 20 | |
20 | |
| 21 | HOMEPAGE="http://www.twistedmatrix.com/" |
21 | HOMEPAGE="http://www.twistedmatrix.com/" |
| 22 | SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/${MY_VERSION}/${MY_P}.tar.bz2" |
22 | SRC_URI="http://tmrc.mit.edu/mirror/twisted/${MY_PACKAGE}/${MY_VERSION}/${MY_P}.tar.bz2" |
| 23 | |
23 | |
| 24 | LICENSE="MIT" |
24 | LICENSE="MIT" |
| 25 | SLOT="0" |
25 | SLOT="0" |
| 26 | |
|
|
| 27 | IUSE="" |
26 | IUSE="" |
| 28 | |
27 | |
| 29 | S="${WORKDIR}/${MY_P}" |
28 | S="${WORKDIR}/${MY_P}" |
| 30 | |
29 | |
| 31 | twisted_src_test() { |
30 | twisted_src_test() { |
| 32 | python_version |
31 | if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
32 | testing() { |
| 33 | # 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 |
| 34 | # filesystem. We copy the twisted site-packages to a temporary |
34 | # filesystem. We copy the twisted site-packages to a temporary |
| 35 | # dir, install there, and run from there. |
35 | # dir, install there, and run from there. |
| 36 | local spath="usr/$(get_libdir)/python${PYVER}/site-packages/" |
36 | local spath="$(python_get_sitedir)" |
| 37 | mkdir -p "${T}/${spath}" |
37 | mkdir -p "${T}/${spath}" |
| 38 | 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}" |
| 39 | |
39 | |
| 40 | # We have to get rid of the existing version of this package |
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 |
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 |
42 | # package has tests in files the version we are installing does |
| 43 | # not have we end up running fex twisted-names-0.3.0 tests when |
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. |
44 | # downgrading to twisted-names-0.1.0-r1. |
| 45 | rm -rf "${T}/${spath}/${PN/-//}" |
45 | rm -fr "${T}/${spath}/${PN/-//}" |
| 46 | |
46 | |
| 47 | if has_version ">=dev-lang/python-2.3"; then |
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 | "${python}" setup.py install --root="${T}" --no-compile --force \ |
48 | cd "${T}/${spath}" || die |
| 49 | --install-lib="${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 |
| 50 | 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 | |
| 51 | "${python}" setup.py install --root="${T}" --force \ |
69 | "${python}" setup.py install --root="${T}" --no-compile --force || die |
| 52 | --install-lib="${spath}" || 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}" |
| 53 | fi |
75 | fi |
| 54 | cd "${T}/${spath}" || die |
|
|
| 55 | local trialopts |
|
|
| 56 | if ! has_version ">=dev-python/twisted-2.2"; then |
|
|
| 57 | trialopts=-R |
|
|
| 58 | fi |
|
|
| 59 | PATH="${T}/usr/bin:${PATH}" PYTHONPATH="${T}/${spath}" \ |
|
|
| 60 | trial ${trialopts} ${PN/-/.} || die "trial failed" |
|
|
| 61 | cd "${S}" |
|
|
| 62 | rm -rf "${T}/${spath}" |
|
|
| 63 | } |
76 | } |
| 64 | |
77 | |
| 65 | twisted_src_install() { |
78 | twisted_src_install() { |
| 66 | python_version |
|
|
| 67 | # The explicit --install-lib here and in src_test is needed to |
|
|
| 68 | # make everything (core and all subpackages) go into lib64 on |
|
|
| 69 | # amd64. Without it pure python subpackages install into lib while |
|
|
| 70 | # stuff with c extensions goes into lib64. |
|
|
| 71 | distutils_src_install \ |
79 | distutils_src_install |
| 72 | --install-lib="usr/$(get_libdir)/python${PYVER}/site-packages/" |
|
|
| 73 | |
80 | |
| 74 | if [[ -d doc/man ]]; then |
81 | if [[ -d doc/man ]]; then |
| 75 | doman doc/man/* |
82 | doman doc/man/* |
| 76 | fi |
83 | fi |
| 77 | |
84 | |
| … | |
… | |
| 81 | fi |
88 | fi |
| 82 | } |
89 | } |
| 83 | |
90 | |
| 84 | update_plugin_cache() { |
91 | update_plugin_cache() { |
| 85 | einfo "Updating twisted plugin cache..." |
92 | einfo "Updating twisted plugin cache..." |
| 86 | python_version |
|
|
| 87 | # 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 |
| 88 | # from the cache (http://twistedmatrix.com/bugs/issue926) |
94 | # from the cache (http://twistedmatrix.com/bugs/issue926) |
| 89 | rm "${ROOT}usr/$(get_libdir)/python${PYVER}/site-packages/twisted/plugins/dropin.cache" |
95 | rm "${ROOT}$(python_get_sitedir)/twisted/plugins/dropin.cache" |
| 90 | # 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 |
| 91 | python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))" |
97 | python -c "from twisted.plugin import IPlugin, getPlugIns;list(getPlugIns(IPlugin))" |
| 92 | } |
98 | } |
| 93 | |
99 | |
| 94 | twisted_pkg_postrm() { |
100 | twisted_pkg_postrm() { |
| 95 | distutils_pkg_postrm |
101 | distutils_pkg_postrm |
|
|
102 | if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
103 | python_execute_function update_plugin_cache |
|
|
104 | else |
| 96 | update_plugin_cache |
105 | update_plugin_cache |
|
|
106 | fi |
| 97 | } |
107 | } |
| 98 | |
108 | |
| 99 | twisted_pkg_postinst() { |
109 | twisted_pkg_postinst() { |
| 100 | distutils_pkg_postinst |
110 | distutils_pkg_postinst |
|
|
111 | if [[ -n "${SUPPORT_PYTHON_ABIS}" ]]; then |
|
|
112 | python_execute_function update_plugin_cache |
|
|
113 | else |
| 101 | update_plugin_cache |
114 | update_plugin_cache |
|
|
115 | fi |
| 102 | } |
116 | } |
| 103 | |
117 | |
| 104 | EXPORT_FUNCTIONS src_test src_install pkg_postrm pkg_postinst |
118 | EXPORT_FUNCTIONS src_test src_install pkg_postrm pkg_postinst |