From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-python@lists.gentoo.org
Cc: python@gentoo.org, "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-python] [PATCH 2/2] Support python-exec:2.
Date: Sun, 15 Sep 2013 11:03:26 +0200 [thread overview]
Message-ID: <1379235806-15800-3-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1379235806-15800-1-git-send-email-mgorny@gentoo.org>
---
gx86/eclass/distutils-r1.eclass | 28 +++++++++++++++++----
gx86/eclass/python-r1.eclass | 38 +++++++++++++++++++++-------
gx86/eclass/python-single-r1.eclass | 8 +++++-
gx86/eclass/python-utils-r1.eclass | 50 ++++++++++++++++++++++++++++++++++---
4 files changed, 106 insertions(+), 18 deletions(-)
diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 985e707..e03e135 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -421,6 +421,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
@@ -432,15 +436,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}" "${ED%/}/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
@@ -475,6 +486,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/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index e006744..d80c7b6 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -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/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass
index 2b099c3..46786ea 100644
--- a/gx86/eclass/python-single-r1.eclass
+++ b/gx86/eclass/python-single-r1.eclass
@@ -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/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 6cf23f0..a15a3f3 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -607,7 +607,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}"
@@ -756,20 +756,30 @@ 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 \
+ _python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \
"${ED%/}/${d}/${barefn}" || die
}
@@ -985,5 +995,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
--
1.8.3.2
next prev parent reply other threads:[~2013-09-15 9:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 2/8] Clean up python_replicate_script() Michał Górny
2013-09-15 17:11 ` [gentoo-python] " Mike Gilbert
2013-09-15 17:36 ` Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 3/8] Clean up python_newscript() Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging Michał Górny
2013-09-14 22:16 ` [gentoo-python] " Mike Gilbert
2013-09-14 22:38 ` Michał Górny
2013-09-14 23:33 ` Mike Gilbert
2013-09-15 9:04 ` Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 6/8] _distutils-r1_wrap_scripts(): do not pass root path explicitly Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper() Michał Górny
2013-09-15 17:27 ` [gentoo-python] " Mike Gilbert
2013-09-13 18:58 ` [gentoo-python] [PATCH 8/8] Support python-exec:2 Michał Górny
2013-09-15 9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
2013-09-15 9:03 ` [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping Michał Górny
2013-09-15 9:03 ` Michał Górny [this message]
2013-09-15 9:29 ` [gentoo-python] [PATCH 2/2] Support python-exec:2 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379235806-15800-3-git-send-email-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-python@lists.gentoo.org \
--cc=python@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox