diff options
| author | James Le Cuirot <chewi@gentoo.org> | 2024-07-25 22:18:03 +0100 |
|---|---|---|
| committer | Michał Górny <mgorny@gentoo.org> | 2024-08-06 10:30:14 +0200 |
| commit | 068fd56ff572b83925acf159e4afcfd01f98f1c8 (patch) | |
| tree | 566121e2f6424c24d502da62f90686169cd130ee /eclass/python-utils-r1.eclass | |
| parent | 9b2def86a9c7fd8821a5b83df7d250fc4c73540f (diff) | |
| download | gentoo-068fd56ff572b83925acf159e4afcfd01f98f1c8.tar.gz gentoo-068fd56ff572b83925acf159e4afcfd01f98f1c8.tar.bz2 gentoo-068fd56ff572b83925acf159e4afcfd01f98f1c8.zip | |
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@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/python-utils-r1.eclass')
| -rw-r--r-- | eclass/python-utils-r1.eclass | 23 |
1 files changed, 23 insertions, 0 deletions
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: |
