[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH 18/25] python-utils-r2.eclass: Remove PYTHON_CONFIG export
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2020-02-29 20:41:54
Message-ID: 20200229204201.99290-19-mgorny () gentoo ! org
[Download RAW message or body]

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/python-utils-r2.eclass   | 41 +++++++++++++++------------------
 eclass/tests/python-utils-r2.sh |  6 ++---
 2 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/eclass/python-utils-r2.eclass b/eclass/python-utils-r2.eclass
index 00bc635ebab4..7c438e59aa6a 100644
--- a/eclass/python-utils-r2.eclass
+++ b/eclass/python-utils-r2.eclass
@@ -268,23 +268,6 @@ _python_export() {
 				export PYTHON=${EPREFIX}/usr/bin/${impl}
 				debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
 				;;
-			PYTHON_CONFIG)
-				local flags val
-
-				case "${impl}" in
-					python*)
-						[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, \
                or requested before it"
-						flags=$("${PYTHON}" -c 'import sysconfig; \
                print(sysconfig.get_config_var("ABIFLAGS") or "")') || die
-						val=${PYTHON}${flags}-config
-						;;
-					*)
-						die "${impl}: obtaining ${var} not supported"
-						;;
-				esac
-
-				export PYTHON_CONFIG=${val}
-				debug-print "${FUNCNAME}: PYTHON_CONFIG = ${PYTHON_CONFIG}"
-				;;
 			PYTHON_PKG_DEP)
 				local d
 				case ${impl} in
@@ -431,20 +414,32 @@ python_get_LIBS() {
 }
 
 # @FUNCTION: python_get_PYTHON_CONFIG
-# @USAGE: [<impl>]
 # @DESCRIPTION:
-# Obtain and print the PYTHON_CONFIG location for the given
-# implementation. If no implementation is provided, ${EPYTHON} will be
-# used.
+# Obtain and print the PYTHON_CONFIG location for ${EPYTHON}.
 #
 # Please note that this function can be used with CPython only.
 # It requires Python installed, and therefore proper build-time
 # dependencies need be added to the ebuild.
 python_get_PYTHON_CONFIG() {
 	debug-print-function ${FUNCNAME} "${@}"
+	[[ ${EPYTHON} ]] || die "EPYTHON must be set before calling ${FUNCNAME}"
+
+	local flags out
+	local PYTHON
+	_python_export PYTHON
 
-	_python_export "${@}" PYTHON_CONFIG
-	echo "${PYTHON_CONFIG}"
+	case ${EPYTHON} in
+		python*)
+			flags=$("${EPYTHON}" -c 'import sysconfig; \
print(sysconfig.get_config_var("ABIFLAGS") or "")') || die \
+			out=${PYTHON}${flags}-config +			;;
+		*)
+			die "${EPYTHON}: obtaining PYTHON_CONFIG not supported"
+			;;
+	esac
+
+	debug-print "${FUNCNAME} -> ${out}"
+	echo "${out}"
 }
 
 # @FUNCTION: python_get_scriptdir
diff --git a/eclass/tests/python-utils-r2.sh b/eclass/tests/python-utils-r2.sh
index 8758f6d20464..0b41a7bcdb53 100755
--- a/eclass/tests/python-utils-r2.sh
+++ b/eclass/tests/python-utils-r2.sh
@@ -79,7 +79,7 @@ if [[ -x /usr/bin/python2.7 ]]; then
 	test_get sitedir python2.7 "/usr/lib*/python2.7/site-packages"
 	test_get includedir python2.7 /usr/include/python2.7
 	test_get library_path python2.7 "/usr/lib*/libpython2.7$(get_libname)"
-	test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config
+	test_get PYTHON_CONFIG python2.7 /usr/bin/python2.7-config
 	test_get CFLAGS python2.7 "*-I/usr/include/python2.7*"
 	test_get LIBS python2.7 "*-lpython2.7*"
 fi
@@ -93,7 +93,7 @@ if [[ -x /usr/bin/python3.6 ]]; then
 	test_get sitedir python3.6 "/usr/lib*/python3.6/site-packages"
 	test_get includedir python3.6 "/usr/include/python3.6${abiflags}"
 	test_get library_path python3.6 "/usr/lib*/libpython3.6${abiflags}$(get_libname)"
-	test_var PYTHON_CONFIG python3_6 "/usr/bin/python3.6${abiflags}-config"
+	test_get PYTHON_CONFIG python3.6 "/usr/bin/python3.6${abiflags}-config"
 	test_get CFLAGS python3.6 "*-I/usr/include/python3.6*"
 	test_get LIBS python3.6 "*-lpython3.6*"
 fi
@@ -107,7 +107,7 @@ if [[ -x /usr/bin/python3.7 ]]; then
 	test_get sitedir python3.7 "/usr/lib/python3.7/site-packages"
 	test_get includedir python3.7 "/usr/include/python3.7${abiflags}"
 	test_get library_path python3.7 "/usr/lib*/libpython3.7${abiflags}$(get_libname)"
-	test_var PYTHON_CONFIG python3_7 "/usr/bin/python3.7${abiflags}-config"
+	test_get PYTHON_CONFIG python3.7 "/usr/bin/python3.7${abiflags}-config"
 	test_get CFLAGS python3.7 "*-I/usr/include/python3.7*"
 	test_get LIBS python3.7 "*-lpython3.7*"
 fi
-- 
2.25.1


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic