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 B139B15800A for ; Wed, 16 Aug 2023 12:17:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 50C1B2BC02E; Wed, 16 Aug 2023 12:17:40 +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 170CA2BC017 for ; Wed, 16 Aug 2023 12:17:40 +0000 (UTC) From: James Le Cuirot To: gentoo-dev Cc: James Le Cuirot Subject: [gentoo-dev] [PATCH v3] python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDEDIR for cross-prefix Date: Wed, 16 Aug 2023 13:16:33 +0100 Message-ID: <20230816121727.15902-1-chewi@gentoo.org> X-Mailer: git-send-email 2.41.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 91812de2-ffe5-41c1-8d26-f05538bc8a1f X-Archives-Hash: 3ea91315c758d5e082e12d280bdb2186 We dynamically determine Python's SITEDIR and INCLUDEDIR using the build host's Python. This breaks down when the build host's prefix differs from the target host's prefix, so chop off the former and prepend the latter. This assumes that each Python implementation is always installed using the same scheme. Meson already makes this assumption, and gpep517 makes a similar assumption to determine Python's stdlib location. We could improve on this and determine these locations using SYSROOT's sysconfigdata file, like gpep517 does, but this seems needlessly complex. We would need to take this approach for PYTHON_LIBPATH and PYTHON_CONFIG, but these are only used by handful of packages. ${BROOT-${EPREFIX}} is needed rather than plain ${BROOT} for the same reason we need it for PYTHON, namely that Portage <3.0.50 was buggy. Signed-off-by: James Le Cuirot --- Note that gpep517 also needs the same treatment, but I'll handle that later. This at least allows Portage itself to be installed. eclass/python-utils-r1.eclass | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 2fffd6d56bf5..f9c6d161d3f3 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -351,6 +351,7 @@ _python_export() { print(sysconfig.get_path("purelib")) EOF ) + PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"} export PYTHON_SITEDIR debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}" ;; @@ -362,6 +363,7 @@ _python_export() { print(sysconfig.get_path("platinclude")) EOF ) + PYTHON_INCLUDEDIR=${ESYSROOT}${PYTHON_INCLUDEDIR#"${BROOT-${EPREFIX}}"} export PYTHON_INCLUDEDIR debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}" -- 2.41.0