commit: 068fd56ff572b83925acf159e4afcfd01f98f1c8
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 25 21:18:03 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Aug 6 08:30:14 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=068fd56f
python-utils-r1.eclass: Add python_get_stdlib helper function
This is just like python_get_sitedir, but it returns the stdlib
directory such as /usr/lib/python3.12. This is useful for locating the
sysconfigdata file.
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
eclass/python-utils-r1.eclass | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index cc33a1c1bffd..45d3da6bb98c 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -332,6 +332,17 @@ _python_export() {
export
PYTHON=${BROOT-${EPREFIX}}/usr/bin/${impl}
debug-print "${FUNCNAME}: PYTHON = ${PYTHON}"
;;
+ PYTHON_STDLIB)
+ [[ -n ${PYTHON} ]] || die "PYTHON needs to be
set for ${var} to be exported, or requested before it"
+ PYTHON_STDLIB=$(
+ "${PYTHON}" - "${EPREFIX}/usr" <<-EOF
|| die
+ import sys, sysconfig
+
print(sysconfig.get_path("stdlib", vars={"installed_base": sys.argv[1]}))
+ EOF
+ )
+ export PYTHON_STDLIB
+ debug-print "${FUNCNAME}: PYTHON_STDLIB =
${PYTHON_STDLIB}"
+ ;;
PYTHON_SITEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be
set for ${var} to be exported, or requested before it"
PYTHON_SITEDIR=$(
@@ -466,6 +477,18 @@ _python_export() {
done
}
+# @FUNCTION: python_get_stdlib
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the 'stdlib' path for the given implementation. If no
+# implementation is provided, ${EPYTHON} will be used.
+python_get_stdlib() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ _python_export "${@}" PYTHON_STDLIB
+ echo "${PYTHON_STDLIB}"
+}
+
# @FUNCTION: python_get_sitedir
# @USAGE: [<impl>]
# @DESCRIPTION: