summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-09-17 13:33:55 +0000
committerMichał Górny <mgorny@gentoo.org>2013-09-17 13:33:55 +0000
commitcf31a0906d5ee8a2fa7dd0097ba2735a01670f2d (patch)
tree81a8e8f675a1284f7f1581461cde1caf57a19237 /eclass
parentStable on amd64 and x86 (diff)
downloadgentoo-2-cf31a0906d5ee8a2fa7dd0097ba2735a01670f2d.tar.gz
gentoo-2-cf31a0906d5ee8a2fa7dd0097ba2735a01670f2d.tar.bz2
gentoo-2-cf31a0906d5ee8a2fa7dd0097ba2735a01670f2d.zip
Support python-exec:2.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog6
-rw-r--r--eclass/distutils-r1.eclass30
-rw-r--r--eclass/python-r1.eclass40
-rw-r--r--eclass/python-single-r1.eclass10
-rw-r--r--eclass/python-utils-r1.eclass54
5 files changed, 116 insertions, 24 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 48da91692992..8ccf51bfc8e6 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for eclass directory
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.970 2013/09/17 13:29:19 tommy Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.971 2013/09/17 13:33:55 mgorny Exp $
+
+ 17 Sep 2013; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass,
+ python-r1.eclass, python-single-r1.eclass, python-utils-r1.eclass:
+ Support python-exec:2.
17 Sep 2013; Thomas Sachau (Tommy[D]) <tommy@gentoo.org>
multilib-build.eclass:
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 1923084d1443..94833623d9e2 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.78 2013/09/17 13:24:39 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.79 2013/09/17 13:33:55 mgorny Exp $
# @ECLASS: distutils-r1
# @MAINTAINER:
@@ -420,6 +420,10 @@ _distutils-r1_wrap_scripts() {
local path=${1}
[[ ${path} ]] || die "${FUNCNAME}: no path given"
+ if ! _python_want_python_exec2; then
+ local PYTHON_SCRIPTDIR=${EPREFIX}/usr/bin
+ fi
+
mkdir -p "${path}/usr/bin" || die
local f
while IFS= read -r -d '' f; do
@@ -431,15 +435,22 @@ _distutils-r1_wrap_scripts() {
if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
debug-print "${FUNCNAME}: matching shebang: ${shebang}"
- local newf=${f%/*}/${basename}-${EPYTHON}
- debug-print "${FUNCNAME}: renaming to ${newf#${path}}"
- mv "${f}" "${newf}" || die
+ if ! _python_want_python_exec2; then
+ local newf=${f%/*}/${basename}-${EPYTHON}
+ debug-print "${FUNCNAME}: renaming to ${newf#${path}}"
+ mv "${f}" "${newf}" || die
+ fi
debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
- _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \
+ _python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \
"${path}${EPREFIX}/usr/bin/${basename}" || die
+ elif _python_want_python_exec2; then
+ debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
+
+ debug-print "${FUNCNAME}: moving to /usr/bin/${basename}"
+ mv "${f}" "${path}${EPREFIX}/usr/bin/${basename}" || die
fi
- done < <(find "${path}/usr/bin" -type f -print0)
+ done < <(find "${path}${PYTHON_SCRIPTDIR}" -type f -print0)
}
# @FUNCTION: distutils-r1_python_install
@@ -474,6 +485,13 @@ distutils-r1_python_install() {
[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
flags+=( --root="${root}" )
+ if [[ ! ${DISTUTILS_SINGLE_IMPL} ]] && _python_want_python_exec2
+ then
+ local PYTHON_SCRIPTDIR
+ python_export PYTHON_SCRIPTDIR
+ flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" )
+ fi
+
esetup.py install "${flags[@]}" "${@}"
if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 6f59c5fdd619..03f2f586c75a 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.60 2013/09/17 13:24:39 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.61 2013/09/17 13:33:55 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -122,7 +122,7 @@ fi
#
# Example value:
# @CODE
-# dev-python/python-exec:0
+# dev-python/python-exec:=
# python_targets_python2_6? ( dev-lang/python:2.6[gdbm] )
# python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
# @CODE
@@ -203,7 +203,13 @@ _python_set_globals() {
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
- PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+ # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
+ # just fix :0 for now since := deps are not supported.
+ if [[ ${EAPI} != 4 ]]; then
+ PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
+ else
+ PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+ fi
}
_python_set_globals
@@ -742,12 +748,26 @@ python_replicate_script() {
debug-print-function ${FUNCNAME} "${@}"
_python_replicate_script() {
- local f
- for f in "${files[@]}"; do
- cp -p "${f}" "${f}-${EPYTHON}" || die
- done
- _python_rewrite_shebang "${EPYTHON}" \
- "${files[@]/%/-${EPYTHON}}"
+ if _python_want_python_exec2; then
+ local PYTHON_SCRIPTDIR
+ python_export PYTHON_SCRIPTDIR
+
+ (
+ exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}"
+ doexe "${files[@]}"
+ )
+
+ _python_rewrite_shebang "${EPYTHON}" \
+ "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
+ else
+ local f
+ for f in "${files[@]}"; do
+ cp -p "${f}" "${f}-${EPYTHON}" || die
+ done
+
+ _python_rewrite_shebang "${EPYTHON}" \
+ "${files[@]/%/-${EPYTHON}}"
+ fi
}
local files=( "${@}" )
@@ -756,7 +776,7 @@ python_replicate_script() {
# install the wrappers
local f
for f; do
- _python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die
+ _python_ln_rel "${ED%/}$(_python_get_wrapper_path)" "${f}" || die
done
}
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 2b099c329122..e3670bf75f06 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.20 2013/09/12 17:31:11 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-single-r1.eclass,v 1.21 2013/09/17 13:33:55 mgorny Exp $
# @ECLASS: python-single-r1
# @MAINTAINER:
@@ -193,7 +193,13 @@ _python_single_set_globals() {
# but no point in making this overcomplex, BDEP doesn't hurt anyone
# 2) python-exec should be built with all targets forced anyway
# but if new targets were added, we may need to force a rebuild
- PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+ # 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
+ # just fix :0 for now since := deps are not supported.
+ if [[ ${EAPI} != 4 ]]; then
+ PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
+ else
+ PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+ fi
}
_python_single_set_globals
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 81acea2b9294..8ef944a66994 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.37 2013/09/17 13:25:58 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.38 2013/09/17 13:33:55 mgorny Exp $
# @ECLASS: python-utils-r1
# @MAINTAINER:
@@ -615,7 +615,7 @@ _python_ln_rel() {
rel_path=../${rel_path}${frseg:+${frseg}/}
fi
done
- rel_path+=${frpath}${1##*/}
+ rel_path+=${frpath}${from##*/}
debug-print "${FUNCNAME}: ${from} -> ${to}"
debug-print "${FUNCNAME}: rel_path = ${rel_path}"
@@ -764,21 +764,31 @@ python_newscript() {
[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
local d=${python_scriptroot:-${DESTTREE}/bin}
+ local wrapd=${d}
local f=${1}
local barefn=${2}
+ local newfn
- local newfn=${barefn}-${EPYTHON}
+ if _python_want_python_exec2; then
+ local PYTHON_SCRIPTDIR
+ python_export PYTHON_SCRIPTDIR
+ d=${PYTHON_SCRIPTDIR#${EPREFIX}}
+ newfn=${barefn}
+ else
+ newfn=${barefn}-${EPYTHON}
+ fi
(
+ dodir "${wrapd}"
exeinto "${d}"
newexe "${f}" "${newfn}" || die
)
_python_rewrite_shebang "${ED%/}/${d}/${newfn}"
# install the wrapper
- _python_ln_rel "${ED%/}"/usr/bin/python-exec \
- "${ED%/}/${d}/${barefn}" || die
+ _python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \
+ "${ED%/}/${wrapd}/${barefn}" || die
}
# @ECLASS-VARIABLE: python_moduleroot
@@ -993,5 +1003,39 @@ python_is_python3() {
[[ ${impl} == python3* ]]
}
+# @FUNCTION: _python_want_python_exec2
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether we should be using python-exec:2.
+_python_want_python_exec2() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # EAPI 4 lacks slot operators, so just fix it on python-exec:0.
+ [[ ${EAPI} == 4 ]] && return 1
+
+ # Check if we cached the result, or someone put an override.
+ if [[ ! ${_PYTHON_WANT_PYTHON_EXEC2+1} ]]; then
+ has_version 'dev-python/python-exec:2'
+ _PYTHON_WANT_PYTHON_EXEC2=$(( ! ${?} ))
+ fi
+
+ # Non-zero means 'yes', zero means 'no'.
+ [[ ${_PYTHON_WANT_PYTHON_EXEC2} != 0 ]]
+}
+
+# @FUNCTION: _python_get_wrapper_path
+# @INTERNAL
+# @DESCRIPTION:
+# Output path to proper python-exec slot.
+_python_get_wrapper_path() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if _python_want_python_exec2; then
+ echo /usr/lib/python-exec/python-exec2
+ else
+ echo /usr/bin/python-exec
+ fi
+}
+
_PYTHON_UTILS_R1=1
fi