commit: 54d6fdbd179f158f4b9e0e21b1b03ff1ae46f404
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 16 12:16:33 2023 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 19 18:28:13 2023 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=54d6fdbd
python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDEDIR for cross-prefix
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 <chewi <AT> gentoo.org>
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
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}"