Skip to content

Instantly share code, notes, and snippets.

@jan-matejka
Created July 10, 2013 19:52
Show Gist options
  • Select an option

  • Save jan-matejka/5969642 to your computer and use it in GitHub Desktop.

Select an option

Save jan-matejka/5969642 to your computer and use it in GitHub Desktop.
--- /var/lib/cportage/portage/eclass/twisted.eclass 2011-12-27 07:54:23.000000000 +0100
+++ twisted-r1.eclass 2013-07-10 21:50:31.925408788 +0200
@@ -2,7 +2,7 @@
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/eclass/twisted.eclass,v 1.10 2011/12/27 06:54:23 floppym Exp $
-# @ECLASS: twisted.eclass
+# @ECLASS: twisted-r1.eclass
# @MAINTAINER:
# Gentoo Python Project <[email protected]>
# @BLURB: Eclass for Twisted packages
@@ -13,13 +13,11 @@
# MY_PACKAGE - Package name suffix (required)
# MY_PV - Package version (optional)
-inherit distutils versionator
+inherit distutils-r1 versionator
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
if [[ "${CATEGORY}/${PN}" == "dev-python/twisted"* ]]; then
- EXPORT_FUNCTIONS src_test
-
MY_PV="${MY_PV:-${PV}}"
MY_P="Twisted${MY_PACKAGE}-${MY_PV}"
@@ -40,12 +38,13 @@
# @DESCRIPTION:
# Twisted plugins, whose cache is regenerated in pkg_postinst() and pkg_postrm() phases.
-twisted_src_test() {
+python_test() {
+ # TODO: this seems to be used only in dev-python/twisted-* packages as
+ # dev-python/twisted-13.0.0 have it's own src_test
if [[ "${CATEGORY}/${PN}" != "dev-python/twisted"* ]]; then
die "${FUNCNAME}() can be used only in dev-python/twisted* packages"
fi
- testing() {
local sitedir="${EPREFIX}$(python_get_sitedir)"
# Copy modules of other Twisted packages from site-packages directory to temporary directory.
@@ -54,19 +53,17 @@
rm -fr "${T}/${sitedir}/${PN/-//}"
# Install modules of current package to temporary directory.
- "$(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)"
+ "${PYTHON}" setup.py build -b "build-${EPYTHON}" install --force --no-compile --root="${T}" || die "Installation into temporary directory failed with $(python_get_implementation) $(python_get_version)"
pushd "${T}/${sitedir}" > /dev/null || return 1
PATH="${T}${EPREFIX}/usr/bin:${PATH}" PYTHONPATH="${T}/${sitedir}" trial ${PN/-/.} || return 1
popd > /dev/null || return 1
rm -fr "${T}/${sitedir}"
- }
- python_execute_function testing
}
-twisted_src_install() {
- distutils_src_install
+twisted-r1_src_install() {
+ distutils-r1_src_install
if [[ -d doc/man ]]; then
doman doc/man/*.[[:digit:]]
@@ -78,21 +75,20 @@
fi
}
-_twisted_update_plugin_cache() {
+_twisted-r1_update_plugin_cache() {
local dir exit_status="0" module
for module in ${TWISTED_PLUGINS}; do
- if [[ -d "${EROOT}$(python_get_sitedir -b)/${module//.//}" ]]; then
- find "${EROOT}$(python_get_sitedir -b)/${module//.//}" -name dropin.cache -print0 | xargs -0 rm -f
+ if [[ -d "${EROOT}$(python_get_sitedir)/${module//.//}" ]]; then
+ find "${EROOT}$(python_get_sitedir)/${module//.//}" -name dropin.cache -print0 | xargs -0 rm -f
fi
done
- if [[ -n "$(type -p "$(PYTHON)")" ]]; then
for module in ${TWISTED_PLUGINS}; do
# http://twistedmatrix.com/documents/current/core/howto/plugin.html
- "$(PYTHON)" -c \
+ "${PYTHON}" -c \
"import sys
-sys.path.insert(0, '${EROOT}$(python_get_sitedir -b)')
+sys.path.insert(0, '${EROOT}$(python_get_sitedir)')
try:
import twisted.plugin
@@ -106,11 +102,10 @@
list(twisted.plugin.getPlugins(twisted.plugin.IPlugin, ${module}))" || exit_status="1"
done
- fi
for module in ${TWISTED_PLUGINS}; do
# Delete empty parent directories.
- local dir="${EROOT}$(python_get_sitedir -b)/${module//.//}"
+ local dir="${EROOT}$(python_get_sitedir)/${module//.//}"
while [[ "${dir}" != "${EROOT%/}" ]]; do
rmdir "${dir}" 2> /dev/null || break
dir="${dir%/*}"
@@ -120,20 +115,10 @@
return "${exit_status}"
}
-twisted_pkg_postinst() {
- distutils_pkg_postinst
- python_execute_function \
- --action-message 'Regeneration of Twisted plugin cache with $(python_get_implementation) $(python_get_version)' \
- --failure-message 'Regeneration of Twisted plugin cache failed with $(python_get_implementation) $(python_get_version)' \
- --nonfatal \
- _twisted_update_plugin_cache
+twisted-r1_pkg_postinst() {
+ _distutils-r1_run_foreach_impl _twisted-r1_update_plugin_cache
}
-twisted_pkg_postrm() {
- distutils_pkg_postrm
- python_execute_function \
- --action-message 'Regeneration of Twisted plugin cache with $(python_get_implementation) $(python_get_version)' \
- --failure-message 'Regeneration of Twisted plugin cache failed with $(python_get_implementation) $(python_get_version)' \
- --nonfatal \
- _twisted_update_plugin_cache
+twisted-r1_pkg_postrm() {
+ _distutils-r1_run_foreach_impl _twisted-r1_update_plugin_cache
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment