summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2017-05-16 21:53:49 +0200
committerFabian Groffen <grobian@gentoo.org>2017-05-16 21:53:49 +0200
commitaf222677e90428f6d82aec56e6a2b7d0520008ba (patch)
tree2759c7d6377f8931f7b284c9330f79b01274d37f
parentbootstrap-prefix.sh: No CPPFLAGS hack on RAP. (diff)
downloadprefix-af222677e90428f6d82aec56e6a2b7d0520008ba.tar.gz
prefix-af222677e90428f6d82aec56e6a2b7d0520008ba.tar.bz2
prefix-af222677e90428f6d82aec56e6a2b7d0520008ba.zip
eclass/python-utils-r1: sync
-rw-r--r--eclass/python-utils-r1.eclass69
1 files changed, 57 insertions, 12 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 95c6e3d4cb..422a8223be 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -47,6 +47,18 @@ _PYTHON_ALL_IMPLS=(
)
readonly _PYTHON_ALL_IMPLS
+# @ECLASS-VARIABLE: PYTHON_COMPAT_NO_STRICT
+# @INTERNAL
+# @DESCRIPTION:
+# Set to a non-empty value in order to make eclass tolerate (ignore)
+# unknown implementations in PYTHON_COMPAT.
+#
+# This is intended to be set by the user when using ebuilds that may
+# have unknown (newer) implementations in PYTHON_COMPAT. The assumption
+# is that the ebuilds are intended to be used within multiple contexts
+# which can involve revisions of this eclass that support a different
+# set of Python implementations.
+
# @FUNCTION: _python_impl_supported
# @USAGE: <impl>
# @INTERNAL
@@ -79,6 +91,7 @@ _python_impl_supported() {
fi
;;
*)
+ [[ ${PYTHON_COMPAT_NO_STRICT} ]] && return 1
die "Invalid implementation in PYTHON_COMPAT: ${impl}"
esac
}
@@ -149,6 +162,38 @@ _python_set_impls() {
fi
}
+# @FUNCTION: _python_impl_matches
+# @USAGE: <impl> <pattern>...
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether the specified <impl> matches at least one
+# of the patterns following it. Return 0 if it does, 1 otherwise.
+#
+# <impl> should be in PYTHON_COMPAT form. The patterns can be either:
+# a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
+# b) '-2' to indicate all Python 2 variants (= !python_is_python3)
+# c) '-3' to indicate all Python 3 variants (= python_is_python3)
+_python_impl_matches() {
+ [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters"
+
+ local impl=${1} pattern
+ shift
+
+ for pattern; do
+ if [[ ${pattern} == -2 ]]; then
+ ! python_is_python3 "${impl}"
+ return
+ elif [[ ${pattern} == -3 ]]; then
+ python_is_python3 "${impl}"
+ return
+ elif [[ ${impl} == ${pattern} ]]; then
+ return 0
+ fi
+ done
+
+ return 1
+}
+
# @ECLASS-VARIABLE: PYTHON
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -706,7 +751,7 @@ python_optimize() {
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
"${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
;;
- python*)
+ python*|pypy3)
# both levels of optimization are separate since 3.5
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
"${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}"
@@ -856,11 +901,19 @@ python_newscript() {
# The <new-path> can either be an absolute target system path (in which
# case it needs to start with a slash, and ${ED} will be prepended to
# it) or relative to the implementation's site-packages directory
-# (then it must not start with a slash).
+# (then it must not start with a slash). The relative path can be
+# specified either using the Python package notation (separated by dots)
+# or the directory notation (using slashes).
#
# When not set explicitly, the modules are installed to the top
# site-packages directory.
#
+# In the relative case, the exact path is determined directly
+# by each python_doscript/python_newscript function. Therefore,
+# python_moduleinto can be safely called before establishing the Python
+# interpreter and/or a single call can be used to set the path correctly
+# for multiple implementations, as can be seen in the following example.
+#
# Example:
# @CODE
# src_install() {
@@ -869,12 +922,6 @@ python_newscript() {
# python_foreach_impl python_domodule baz.py
# }
# @CODE
-
-# 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} "${@}"
@@ -1016,11 +1063,9 @@ python_wrapper_setup() {
# CPython-specific
if [[ ${EPYTHON} == python* ]]; then
- python_export "${impl}" PYTHON_CONFIG
-
cat > "${workdir}/bin/python-config" <<-_EOF_ || die
#!/bin/sh
- exec "${PYTHON_CONFIG}" "\${@}"
+ exec "${PYTHON}-config" "\${@}"
_EOF_
cp "${workdir}/bin/python-config" \
"${workdir}/bin/python${pyver}-config" || die
@@ -1042,7 +1087,7 @@ python_wrapper_setup() {
for x in "${nonsupp[@]}"; do
cat >"${workdir}"/bin/${x} <<-_EOF_ || die
#!/bin/sh
- echo "${x} is not supported by ${EPYTHON}" >&2
+ echo "${ECLASS}: ${FUNCNAME}: ${x} is not supported by ${EPYTHON} (PYTHON_COMPAT)" >&2
exit 127
_EOF_
chmod +x "${workdir}"/bin/${x} || die