From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D2A8C159C9B for ; Tue, 6 Aug 2024 08:47:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7C4412BC05D; Tue, 6 Aug 2024 08:47:20 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4CC9F2BC05D for ; Tue, 6 Aug 2024 08:47:20 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 02848342FF9 for ; Tue, 6 Aug 2024 08:47:19 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 36B0D1EC3 for ; Tue, 6 Aug 2024 08:47:16 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1722933014.068fd56ff572b83925acf159e4afcfd01f98f1c8.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/python-utils-r1.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 068fd56ff572b83925acf159e4afcfd01f98f1c8 X-VCS-Branch: master Date: Tue, 6 Aug 2024 08:47:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ab8bc62b-e7aa-43b3-b8b6-26ada59ee2f7 X-Archives-Hash: dcadc2e1f59df438bf6cfa4f96062b8d commit: 068fd56ff572b83925acf159e4afcfd01f98f1c8 Author: James Le Cuirot gentoo org> AuthorDate: Thu Jul 25 21:18:03 2024 +0000 Commit: Michał Górny gentoo 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 gentoo.org> Signed-off-by: Michał Górny 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: [] +# @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: [] # @DESCRIPTION: