Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 10/30] python-utils-r1.eclass: Inline python_is_installed
Date: Sun, 06 Feb 2022 12:52:23
Message-Id: 20220206124841.1299133-11-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/30] One batch of Python eclass updates to rule them all by "Michał Górny"
1 Inline the python_is_installed function that is used exactly once
2 (in _python_run_check_deps). This helps us avoid having to grab
3 PYTHON_PKG_DEP twice.
4
5 Signed-off-by: Michał Górny <mgorny@g.o>
6 ---
7 eclass/python-utils-r1.eclass | 22 +++-------------------
8 1 file changed, 3 insertions(+), 19 deletions(-)
9
10 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
11 index 2a83ef463ffd..3d938f5ee74f 100644
12 --- a/eclass/python-utils-r1.eclass
13 +++ b/eclass/python-utils-r1.eclass
14 @@ -995,24 +995,6 @@ python_is_python3() {
15 [[ ${impl} == python3* || ${impl} == pypy3 ]]
16 }
17
18 -# @FUNCTION: python_is_installed
19 -# @USAGE: [<impl>]
20 -# @DESCRIPTION:
21 -# Check whether the interpreter for <impl> (or ${EPYTHON}) is installed.
22 -# Uses has_version with a proper dependency string.
23 -#
24 -# Returns 0 (true) if it is, 1 (false) otherwise.
25 -python_is_installed() {
26 - local impl=${1:-${EPYTHON}}
27 - [[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
28 - local hasv_args=( -b )
29 - [[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
30 -
31 - local PYTHON_PKG_DEP
32 - _python_export "${impl}" PYTHON_PKG_DEP
33 - has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
34 -}
35 -
36 # @FUNCTION: python_fix_shebang
37 # @USAGE: [-f|--force] [-q|--quiet] <path>...
38 # @DESCRIPTION:
39 @@ -1379,13 +1361,15 @@ _python_run_check_deps() {
40 debug-print-function ${FUNCNAME} "${@}"
41
42 local impl=${1}
43 + local hasv_args=( -b )
44 + [[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
45
46 einfo "Checking whether ${impl} is suitable ..."
47
48 local PYTHON_PKG_DEP
49 _python_export "${impl}" PYTHON_PKG_DEP
50 ebegin " ${PYTHON_PKG_DEP}"
51 - python_is_installed "${impl}"
52 + has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
53 eend ${?} || return 1
54 declare -f python_check_deps >/dev/null || return 0
55
56 --
57 2.35.1