public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH v3] python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDEDIR for cross-prefix
@ 2023-08-16 12:16 James Le Cuirot
  2023-08-19 18:27 ` Michał Górny
  0 siblings, 1 reply; 2+ messages in thread
From: James Le Cuirot @ 2023-08-16 12:16 UTC (permalink / raw
  To: gentoo-dev; +Cc: James Le Cuirot

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@gentoo.org>
---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-dev] [PATCH v3] python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDEDIR for cross-prefix
  2023-08-16 12:16 [gentoo-dev] [PATCH v3] python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDEDIR for cross-prefix James Le Cuirot
@ 2023-08-19 18:27 ` Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2023-08-19 18:27 UTC (permalink / raw
  To: gentoo-dev; +Cc: James Le Cuirot

On Wed, 2023-08-16 at 13:16 +0100, James Le Cuirot wrote:
> 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@gentoo.org>
> ---
> 
> 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
> 

Pushed (along with some other pending changes), thanks!

-- 
Best regards,
Michał Górny



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-19 18:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 12:16 [gentoo-dev] [PATCH v3] python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDEDIR for cross-prefix James Le Cuirot
2023-08-19 18:27 ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox