python-utils: Update to upstream
This is needed for upgrading ws4py, gevent, and greenlet.
This maintains the fix from crrev.com/c/1440268.
See crrev.com/c/1904637.
BUG=chromium:1022557, b:144061947
TEST=CQ+1
Change-Id: I4b8ef70c504869415fe3da8405da6f1a054ec71b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/eclass-overlay/+/2010345
Tested-by: Craig Hesling <hesling@chromium.org>
Commit-Queue: Craig Hesling <hesling@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 368b268..f95981a 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: python-utils-r1.eclass
@@ -7,7 +7,7 @@
# @AUTHOR:
# Author: MichaĆ Górny <mgorny@gentoo.org>
# Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
+# @SUPPORTED_EAPIS: 5 6 7
# @BLURB: Utility functions for packages with Python parts.
# @DESCRIPTION:
# A utility eclass providing functions to query Python implementations,
@@ -20,11 +20,9 @@
# https://wiki.gentoo.org/wiki/Project:Python/python-utils-r1
case "${EAPI:-0}" in
- 0|1|2|3|4|5|6|7)
- ;;
- *)
- die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
- ;;
+ [0-4]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;;
+ [5-7]) ;;
+ *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;;
esac
if [[ ${_PYTHON_ECLASS_INHERITED} ]]; then
@@ -33,7 +31,7 @@
if [[ ! ${_PYTHON_UTILS_R1} ]]; then
-[[ ${EAPI:-0} == [012345] ]] && inherit eutils multilib
+[[ ${EAPI} == 5 ]] && inherit eutils multilib
inherit toolchain-funcs
# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
@@ -41,10 +39,9 @@
# @DESCRIPTION:
# All supported Python implementations, most preferred last.
_PYTHON_ALL_IMPLS=(
- jython2_7
- pypy pypy3
+ pypy3
python2_7
- python3_4 python3_5 python3_6 python3_7
+ python3_6 python3_7 python3_8
)
readonly _PYTHON_ALL_IMPLS
@@ -80,17 +77,12 @@
# keep in sync with _PYTHON_ALL_IMPLS!
# (not using that list because inline patterns shall be faster)
case "${impl}" in
- python2_7|python3_[4567]|jython2_7)
+ python2_7|python3_[678]|pypy3)
return 0
;;
- pypy1_[89]|pypy2_0|python2_[56]|python3_[123])
+ jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
return 1
;;
- pypy|pypy3)
- if [[ ${EAPI:-0} == [01234] ]]; then
- die "PyPy is supported in EAPI 5 and newer only."
- fi
- ;;
*)
[[ ${PYTHON_COMPAT_NO_STRICT} ]] && return 1
die "Invalid implementation in PYTHON_COMPAT: ${impl}"
@@ -164,11 +156,12 @@
}
# @FUNCTION: _python_impl_matches
-# @USAGE: <impl> <pattern>...
+# @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.
+# Matches if no patterns are provided.
#
# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be
# either:
@@ -176,17 +169,17 @@
# 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"
+ [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter"
+ [[ ${#} -eq 1 ]] && return 0
local impl=${1} pattern
shift
for pattern; do
if [[ ${pattern} == -2 ]]; then
- ! python_is_python3 "${impl}"
- return
+ python_is_python3 "${impl}" || return 0
elif [[ ${pattern} == -3 ]]; then
- python_is_python3 "${impl}"
+ python_is_python3 "${impl}" && return 0
return
# unify value style to allow lax matching
elif [[ ${impl/./_} == ${pattern/./_} ]]; then
@@ -479,9 +472,9 @@
python*)
PYTHON_PKG_DEP="dev-lang/python:${impl#python}";;
pypy)
- PYTHON_PKG_DEP='>=virtual/pypy-5:0=';;
+ PYTHON_PKG_DEP='>=dev-python/pypy-5:0=';;
pypy3)
- PYTHON_PKG_DEP='>=virtual/pypy3-5:0=';;
+ PYTHON_PKG_DEP='>=dev-python/pypy3-5:0=';;
jython2.7)
PYTHON_PKG_DEP='dev-java/jython:2.7';;
*)
@@ -692,7 +685,7 @@
if [[ ${f} == /* && -d ${D%/}${f} ]]; then
set -- "${D%/}${f}" "${@}"
fi
- done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die)
+ done < <("${PYTHON}" -c 'import sys; print("".join(x + "\0" for x in sys.path))' || die)
debug-print "${FUNCNAME}: using sys.path: ${*/%/;}"
fi
@@ -775,9 +768,6 @@
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
- if [[ ${EAPI:-0} == [0123] ]]; then
- die "python_do* and python_new* helpers are banned in EAPIs older than 4."
- fi
local wrapd=${python_scriptroot:-/usr/bin}
@@ -905,9 +895,6 @@
debug-print-function ${FUNCNAME} "${@}"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
- if [[ ${EAPI:-0} == [0123] ]]; then
- die "python_do* and python_new* helpers are banned in EAPIs older than 4."
- fi
local d
if [[ ${python_moduleroot} == /* ]]; then
@@ -947,9 +934,6 @@
debug-print-function ${FUNCNAME} "${@}"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
- if [[ ${EAPI:-0} == [0123] ]]; then
- die "python_do* and python_new* helpers are banned in EAPIs older than 4."
- fi
local d PYTHON_INCLUDEDIR=${PYTHON_INCLUDEDIR}
[[ ${PYTHON_INCLUDEDIR} ]] || python_export PYTHON_INCLUDEDIR
@@ -1092,10 +1076,7 @@
[[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
local hasv_args=()
- case ${EAPI:-0} in
- 0|1|2|3|4)
- local -x ROOT=/
- ;;
+ case ${EAPI} in
5|6)
hasv_args+=( --host-root )
;;
@@ -1264,7 +1245,7 @@
if [[ ! ${any_fixed} ]]; then
local cmd=eerror
- [[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn
+ [[ ${EAPI} == 5 ]] && cmd=eqawarn
"${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files."
if [[ ${any_correct} ]]; then
@@ -1344,6 +1325,31 @@
return 0
}
+# @FUNCTION: build_sphinx
+# @USAGE: <directory>
+# @DESCRIPTION:
+# Build HTML documentation using dev-python/sphinx in the specified
+# <directory>. Takes care of disabling Intersphinx and appending
+# to HTML_DOCS.
+#
+# If <directory> is relative to the current directory, care needs
+# to be taken to run einstalldocs from the same directory
+# (usually ${S}).
+build_sphinx() {
+ debug-print-function ${FUNCNAME} "${@}"
+ [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes 1 arg: <directory>"
+
+ local dir=${1}
+
+ sed -i -e 's:^intersphinx_mapping:disabled_&:' \
+ "${dir}"/conf.py || die
+ # not all packages include the Makefile in pypi tarball
+ sphinx-build -b html -d "${dir}"/_build/doctrees "${dir}" \
+ "${dir}"/_build/html || die
+
+ HTML_DOCS+=( "${dir}/_build/html/." )
+}
+
# -- python.eclass functions --
_python_check_dead_variables() {