diff options
author | Michał Górny <mgorny@gentoo.org> | 2012-11-21 09:04:14 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2012-11-21 09:04:14 +0000 |
commit | cd7bc46024e6f9b63f2c91fb925b3c768741177a (patch) | |
tree | a40872a50210da7187d48056db32fff024314ca4 /eclass/python-r1.eclass | |
parent | Introduce python_doscript() to install Python scripts. (diff) | |
download | gentoo-2-cd7bc46024e6f9b63f2c91fb925b3c768741177a.tar.gz gentoo-2-cd7bc46024e6f9b63f2c91fb925b3c768741177a.tar.bz2 gentoo-2-cd7bc46024e6f9b63f2c91fb925b3c768741177a.zip |
Introduce python_domodule() to install Python modules.
Diffstat (limited to 'eclass/python-r1.eclass')
-rw-r--r-- | eclass/python-r1.eclass | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 552341fd8ac5..84dc50fe6951 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.19 2012/11/21 09:01:50 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.20 2012/11/21 09:04:14 mgorny Exp $ # @ECLASS: python-r1 # @MAINTAINER: @@ -816,3 +816,87 @@ python_doscript() { _python_ln_rel "${ED}"/usr/bin/python-exec "${D}/${d}/${oldfn}" || die done } + +# @ECLASS-VARIABLE: python_moduleroot +# @DEFAULT_UNSET +# @DESCRIPTION: +# The current module root for python_domodule(). The path can be either +# an absolute system path (it must start with a slash, and ${D} will be +# prepended to it) or relative to the implementation's site-packages directory +# (then it must start with a non-slash character). +# +# When unset, the modules will be installed in the site-packages root. +# +# Can be set indirectly through the python_moduleinto() function. +# +# Example: +# @CODE +# src_install() { +# local python_moduleroot=bar +# # installs ${PYTHON_SITEDIR}/bar/baz.py +# python_foreach_impl python_domodule baz.py +# } +# @CODE + +# @FUNCTION: python_moduleinto +# @USAGE: <new-path> +# @DESCRIPTION: +# Set the current module root. The new value will be stored +# in the 'python_moduleroot' environment variable. The new value need +# be relative to the site-packages root. +# +# Alternatively, you can set the variable directly. +python_moduleinto() { + debug-print-function ${FUNCNAME} "${@}" + + python_moduleroot=${1} +} + +# @FUNCTION: python_domodule +# @USAGE: <files>... +# @DESCRIPTION: +# Install the given modules (or packages) into the current +# python_moduleroot. The list can mention both modules (files) +# and packages (directories). All listed files will be installed +# for all enabled implementations, and compiled afterwards. +# +# Example: +# @CODE +# src_install() { +# # (${PN} being a directory) +# python_foreach_impl python_domodule ${PN} +# } +# @CODE +python_domodule() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' + + local d + if [[ ${python_moduleroot} == /* ]]; then + # absolute path + d=${python_moduleroot} + else + # relative to site-packages + local PYTHON_SITEDIR=${PYTHON_SITEDIR} + [[ ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR + + d=${PYTHON_SITEDIR}/${python_moduleroot} + fi + + local INSDESTTREE + + insinto "${d}" + doins -r "${@}" + + # erm, python2.6 can't handle passing files to compileall... + case "${EPYTHON}" in + python*) + "${PYTHON}" -m compileall -q "${D}/${d}" + "${PYTHON}" -OO -m compileall -q -f "${D}/${d}" + ;; + *) + "${PYTHON}" -m compileall -q "${D}/${d}" + ;; + esac +} |