From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/prefix:master commit in: eclass/
Date: Sat, 10 Apr 2021 07:09:07 +0000 (UTC) [thread overview]
Message-ID: <1618038532.576b06627578c9846b2b265085c13509692ea49f.sam@gentoo> (raw)
commit: 576b06627578c9846b2b265085c13509692ea49f
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 10 07:08:52 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Apr 10 07:08:52 2021 +0000
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=576b0662
python-utils-r1.eclass: sync with ::gentoo
Signed-off-by: Sam James <sam <AT> gentoo.org>
eclass/python-utils-r1.eclass | 304 +++++++++++-------------------------------
1 file changed, 81 insertions(+), 223 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 1b1f6b4d4b..88b258a7f6 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 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: 5 6 7
+# @SUPPORTED_EAPIS: 6 7
# @BLURB: Utility functions for packages with Python parts.
# @DESCRIPTION:
# A utility eclass providing functions to query Python implementations,
@@ -19,9 +19,12 @@
# For more information, please see the Python Guide:
# https://dev.gentoo.org/~mgorny/python-guide/
+# NOTE: When dropping support for EAPIs here, we need to update
+# metadata/install-qa-check.d/60python-pyc
+# See bug #704286, bug #781878
case "${EAPI:-0}" in
- [0-4]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;;
- [5-7]) ;;
+ [0-5]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;;
+ [6-7]) ;;
*) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;;
esac
@@ -31,7 +34,6 @@ fi
if [[ ! ${_PYTHON_UTILS_R1} ]]; then
-[[ ${EAPI} == 5 ]] && inherit eutils multilib
inherit toolchain-funcs
# @ECLASS-VARIABLE: _PYTHON_ALL_IMPLS
@@ -40,8 +42,7 @@ inherit toolchain-funcs
# All supported Python implementations, most preferred last.
_PYTHON_ALL_IMPLS=(
pypy3
- python2_7
- python3_6 python3_7 python3_8 python3_9
+ python3_7 python3_8 python3_9
)
readonly _PYTHON_ALL_IMPLS
@@ -52,8 +53,8 @@ readonly _PYTHON_ALL_IMPLS
_PYTHON_HISTORICAL_IMPLS=(
jython2_7
pypy pypy1_{8,9} pypy2_0
- python2_{5,6}
- python3_{1,2,3,4,5}
+ python2_{5..7}
+ python3_{1..6}
)
readonly _PYTHON_HISTORICAL_IMPLS
@@ -69,38 +70,6 @@ readonly _PYTHON_HISTORICAL_IMPLS
# which can involve revisions of this eclass that support a different
# set of Python implementations.
-# @FUNCTION: _python_impl_supported
-# @USAGE: <impl>
-# @INTERNAL
-# @DESCRIPTION:
-# Check whether the implementation <impl> (PYTHON_COMPAT-form)
-# is still supported.
-#
-# Returns 0 if the implementation is valid and supported. If it is
-# unsupported, returns 1 -- and the caller should ignore the entry.
-# If it is invalid, dies with an appopriate error messages.
-_python_impl_supported() {
- debug-print-function ${FUNCNAME} "${@}"
-
- [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl)."
-
- local impl=${1}
-
- # keep in sync with _PYTHON_ALL_IMPLS!
- # (not using that list because inline patterns shall be faster)
- case "${impl}" in
- python2_7|python3_[6789]|pypy3)
- return 0
- ;;
- jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
- return 1
- ;;
- *)
- [[ ${PYTHON_COMPAT_NO_STRICT} ]] && return 1
- die "Invalid implementation in PYTHON_COMPAT: ${impl}"
- esac
-}
-
# @FUNCTION: _python_verify_patterns
# @USAGE: <pattern>...
# @INTERNAL
@@ -149,10 +118,26 @@ _python_set_impls() {
if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
die 'PYTHON_COMPAT must be an array.'
fi
- for i in "${PYTHON_COMPAT[@]}"; do
- # trigger validity checks
- _python_impl_supported "${i}"
- done
+ if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then
+ for i in "${PYTHON_COMPAT[@]}"; do
+ # check for incorrect implementations
+ # we're using pattern matching as an optimization
+ # please keep them in sync with _PYTHON_ALL_IMPLS
+ # and _PYTHON_HISTORICAL_IMPLS
+ case ${i} in
+ jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9])
+ ;;
+ *)
+ if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" \
+ "${_PYTHON_HISTORICAL_IMPLS[@]}"
+ then
+ die "Mis-synced patterns in _python_set_impls: missing ${i}"
+ else
+ die "Invalid implementation in PYTHON_COMPAT: ${i}"
+ fi
+ esac
+ done
+ fi
local supp=() unsupp=()
@@ -165,7 +150,13 @@ _python_set_impls() {
done
if [[ ! ${supp[@]} ]]; then
- die "No supported implementation in PYTHON_COMPAT."
+ # special-case python2_7 for python-any-r1
+ if [[ ${_PYTHON_ALLOW_PY27} ]] && has python2_7 "${PYTHON_COMPAT[@]}"
+ then
+ supp+=( python2_7 )
+ else
+ die "No supported implementation in PYTHON_COMPAT."
+ fi
fi
if [[ ${_PYTHON_SUPPORTED_IMPLS[@]} ]]; then
@@ -636,6 +627,7 @@ python_optimize() {
local PYTHON=${PYTHON}
[[ ${PYTHON} ]] || _python_export PYTHON
+ [[ -x ${PYTHON} ]] || die "PYTHON (${PYTHON}) is not executable"
# default to sys.path
if [[ ${#} -eq 0 ]]; then
@@ -950,8 +942,6 @@ _python_wrapper_setup() {
[[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON specified."
if [[ ! -x ${workdir}/bin/python ]]; then
- _python_check_dead_variables
-
mkdir -p "${workdir}"/{bin,pkgconfig} || die
# Clean up, in case we were supposed to do a cheap update.
@@ -1058,16 +1048,8 @@ python_is_python3() {
python_is_installed() {
local impl=${1:-${EPYTHON}}
[[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
- local hasv_args=()
-
- case ${EAPI} in
- 5|6)
- hasv_args+=( --host-root )
- ;;
- *)
- hasv_args+=( -b )
- ;;
- esac
+ local hasv_args=( -b )
+ [[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
local PYTHON_PKG_DEP
_python_export "${impl}" PYTHON_PKG_DEP
@@ -1214,17 +1196,14 @@ python_fix_shebang() {
done < <(find -H "${path}" -type f -print0 || die)
if [[ ! ${any_fixed} ]]; then
- local cmd=eerror
- [[ ${EAPI} == 5 ]] && cmd=eqawarn
-
- "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files."
+ eerror "QA error: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files."
if [[ ${any_correct} ]]; then
- "${cmd}" "All files have ${EPYTHON} shebang already."
+ eerror "All files have ${EPYTHON} shebang already."
else
- "${cmd}" "There are no Python files in specified directory."
+ eerror "There are no Python files in specified directory."
fi
- [[ ${cmd} == eerror ]] && die "${FUNCNAME} did not match any fixable files (QA warning fatal in EAPI ${EAPI})"
+ die "${FUNCNAME} did not match any fixable files"
fi
done
}
@@ -1321,172 +1300,51 @@ build_sphinx() {
HTML_DOCS+=( "${dir}/_build/html/." )
}
-# -- python.eclass functions --
-
-_python_check_dead_variables() {
- local v
-
- for v in PYTHON_DEPEND PYTHON_USE_WITH{,_OR,_OPT} {RESTRICT,SUPPORT}_PYTHON_ABIS
- do
- if [[ ${!v} ]]; then
- die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Ebuild_head"
- fi
- done
-
- for v in PYTHON_{CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGS}
- do
- if [[ ${!v} ]]; then
- die "${v} is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#PYTHON_CFLAGS"
- fi
- done
-
- for v in PYTHON_TESTS_RESTRICTED_ABIS PYTHON_EXPORT_PHASE_FUNCTIONS \
- PYTHON_VERSIONED_{SCRIPTS,EXECUTABLES} PYTHON_NONVERSIONED_EXECUTABLES
- do
- if [[ ${!v} ]]; then
- die "${v} is invalid for python-r1 suite"
- fi
- done
-
- for v in DISTUTILS_USE_SEPARATE_SOURCE_DIRECTORIES DISTUTILS_SETUP_FILES \
- DISTUTILS_GLOBAL_OPTIONS DISTUTILS_SRC_TEST PYTHON_MODNAME
- do
- if [[ ${!v} ]]; then
- die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#${v}"
- fi
- done
-
- if [[ ${DISTUTILS_DISABLE_TEST_DEPENDENCY} ]]; then
- die "${v} is invalid for distutils-r1, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#DISTUTILS_SRC_TEST"
- fi
-
- # python.eclass::progress
- for v in PYTHON_BDEPEND PYTHON_MULTIPLE_ABIS PYTHON_ABI_TYPE \
- PYTHON_RESTRICTED_ABIS PYTHON_TESTS_FAILURES_TOLERANT_ABIS \
- PYTHON_CFFI_MODULES_GENERATION_COMMANDS
- do
- if [[ ${!v} ]]; then
- die "${v} is invalid for python-r1 suite"
- fi
- done
-}
-
-python_pkg_setup() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
-}
-
-python_convert_shebangs() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_convert_shebangs"
-}
-
-python_clean_py-compile_files() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_clean_installation_image() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_execute_function() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#python_execute_function"
-}
-
-python_generate_wrapper_scripts() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_merge_intermediate_installation_images() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_set_active_version() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#pkg_setup"
-}
-
-python_need_rebuild() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-PYTHON() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#.24.28PYTHON.29.2C_.24.7BEPYTHON.7D"
-}
-
-python_get_implementation() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_get_implementational_package() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_get_libdir() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_get_library() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_get_version() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_get_implementation_and_version() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_execute_nosetests() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_execute_py.test() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_execute_trial() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_enable_pyc() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_disable_pyc() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
-
-python_mod_optimize() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
-}
-
-python_mod_cleanup() {
- die "${FUNCNAME}() is invalid for python-r1 suite, please take a look @ https://wiki.gentoo.org/wiki/Project:Python/Python.eclass_conversion#Python_byte-code_compilation"
-}
+# @FUNCTION: epytest
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Run pytest, passing the standard set of pytest options, followed
+# by user-specified options.
+#
+# This command dies on failure and respects nonfatal.
+epytest() {
+ debug-print-function ${FUNCNAME} "${@}"
-# python.eclass::progress
+ [[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context"
-python_abi_depend() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
+ local args=(
+ # verbose progress reporting and tracebacks
+ -vv
+ # list all non-passed tests in the summary for convenience
+ # (includes failures, skips, xfails...)
+ -ra
+ # print local variables in tracebacks, useful for debugging
+ -l
+ )
+ set -- "${EPYTHON}" -m pytest "${args[@]}" "${@}"
-python_install_executables() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
+ echo "${@}" >&2
+ "${@}" || die -n "pytest failed with ${EPYTHON}"
+ return ${?}
}
-python_get_extension_module_suffix() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
+# @FUNCTION: eunittest
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Run unit tests using dev-python/unittest-or-fail, passing the standard
+# set of options, followed by user-specified options.
+#
+# This command dies on failure and respects nonfatal.
+eunittest() {
+ debug-print-function ${FUNCNAME} "${@}"
-python_byte-compile_modules() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
+ [[ -n ${EPYTHON} ]] || die "EPYTHON unset, invalid call context"
-python_clean_byte-compiled_modules() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
-}
+ set -- "${EPYTHON}" -m unittest_or_fail discover -v "${@}"
-python_generate_cffi_modules() {
- die "${FUNCNAME}() is invalid for python-r1 suite"
+ echo "${@}" >&2
+ "${@}" || die -n "Tests failed with ${EPYTHON}"
+ return ${?}
}
_PYTHON_UTILS_R1=1
next reply other threads:[~2021-04-10 7:09 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-10 7:09 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-09-30 9:08 [gentoo-commits] repo/proj/prefix:master commit in: eclass/ Fabian Groffen
2024-09-23 18:25 Fabian Groffen
2024-08-11 16:19 Fabian Groffen
2024-08-10 14:43 Fabian Groffen
2024-08-10 14:24 Fabian Groffen
2024-08-10 14:24 Fabian Groffen
2024-08-10 10:48 Fabian Groffen
2024-08-09 9:25 Fabian Groffen
2024-08-07 17:08 Fabian Groffen
2024-08-07 17:03 Fabian Groffen
2024-07-25 6:25 Fabian Groffen
2024-07-17 12:01 Fabian Groffen
2024-05-09 7:14 Fabian Groffen
2024-01-21 13:47 Fabian Groffen
2024-01-21 13:43 Fabian Groffen
2024-01-21 13:40 Fabian Groffen
2023-12-16 15:36 Fabian Groffen
2023-09-11 23:33 Sam James
2023-09-04 6:36 Fabian Groffen
2023-09-03 19:39 Fabian Groffen
2023-05-24 7:55 Fabian Groffen
2023-05-24 6:19 Fabian Groffen
2022-06-29 14:53 Sam James
2022-06-29 14:05 Sam James
2022-06-07 17:01 Fabian Groffen
2022-06-07 12:35 Fabian Groffen
2022-06-06 16:51 Fabian Groffen
2022-06-06 9:07 Fabian Groffen
2022-06-06 8:42 Fabian Groffen
2022-05-10 6:22 Fabian Groffen
2022-02-17 0:12 Sam James
2022-02-10 8:54 Fabian Groffen
2022-01-31 1:07 Sam James
2022-01-23 2:27 Sam James
2022-01-23 1:21 Sam James
2021-12-03 10:03 Fabian Groffen
2021-10-21 6:39 Fabian Groffen
2021-10-14 6:15 Sam James
2021-10-14 6:15 Sam James
2021-10-13 4:05 Sam James
2021-07-13 9:02 Fabian Groffen
2021-06-29 6:48 Fabian Groffen
2021-06-29 6:23 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:20 Fabian Groffen
2021-05-04 17:09 Fabian Groffen
2021-04-10 7:15 Sam James
2021-04-10 7:15 Sam James
2021-04-10 7:15 Sam James
2021-03-13 9:54 Fabian Groffen
2021-02-07 19:23 Fabian Groffen
2021-01-24 9:47 Fabian Groffen
2021-01-14 8:02 Fabian Groffen
2021-01-12 13:32 Fabian Groffen
2021-01-11 19:53 Fabian Groffen
2020-12-15 7:48 Fabian Groffen
2020-11-29 14:24 Fabian Groffen
2020-11-29 13:41 Fabian Groffen
2020-08-09 8:14 Fabian Groffen
2020-06-22 18:28 Fabian Groffen
2020-06-22 13:56 Fabian Groffen
2020-05-26 6:44 Fabian Groffen
2020-03-26 7:56 Fabian Groffen
2020-03-22 9:25 Fabian Groffen
2020-03-16 17:23 Michael Haubenwallner
2020-03-13 7:51 Fabian Groffen
2019-12-11 9:47 Fabian Groffen
2019-11-14 6:36 Fabian Groffen
2019-05-30 8:25 Fabian Groffen
2019-03-25 14:20 Michael Haubenwallner
2018-12-17 9:55 Fabian Groffen
2018-07-17 8:45 Fabian Groffen
2018-07-03 8:52 Michael Haubenwallner
2018-06-22 13:16 Michael Haubenwallner
2018-06-20 7:32 Fabian Groffen
2018-06-06 12:48 Fabian Groffen
2017-12-12 18:53 Fabian Groffen
2017-12-12 18:53 Fabian Groffen
2017-10-17 8:39 Fabian Groffen
2017-10-16 13:54 Fabian Groffen
2017-10-03 7:38 Michael Haubenwallner
2016-07-08 11:17 Fabian Groffen
2016-06-15 11:32 [gentoo-commits] repo/proj/prefix:rap0 " Benda XU
2016-06-15 11:05 ` [gentoo-commits] repo/proj/prefix:master " Benda XU
2016-04-18 8:07 Michael Haubenwallner
2016-03-20 18:22 Fabian Groffen
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=1618038532.576b06627578c9846b2b265085c13509692ea49f.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.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