* [gentoo-dev] [PATCH] python-utils-r1.eclass: Redo cross-prefix support using sysconfig
@ 2023-08-25 21:18 James Le Cuirot
2023-08-26 4:09 ` Michał Górny
0 siblings, 1 reply; 3+ messages in thread
From: James Le Cuirot @ 2023-08-25 21:18 UTC (permalink / raw
To: gentoo-dev; +Cc: James Le Cuirot
We recently supported cross-prefix by rewriting PYTHON_SITEDIR and
PYTHON_INCLUDEDIR from BROOT to EPREFIX. We now know that you can get
sysconfig to use EPREFIX in the first place, which is cleaner.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
eclass/python-utils-r1.eclass | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index f9c6d161d3f3..bd30c1203180 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -346,24 +346,22 @@ _python_export() {
PYTHON_SITEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
PYTHON_SITEDIR=$(
- "${PYTHON}" - <<-EOF || die
- import sysconfig
- print(sysconfig.get_path("purelib"))
+ "${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die
+ import sys, sysconfig
+ print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))
EOF
)
- PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"}
export PYTHON_SITEDIR
debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
;;
PYTHON_INCLUDEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
PYTHON_INCLUDEDIR=$(
- "${PYTHON}" - <<-EOF || die
- import sysconfig
- print(sysconfig.get_path("platinclude"))
+ "${PYTHON}" - "${ESYSROOT}/usr" <<-EOF || die
+ import sys, sysconfig
+ print(sysconfig.get_path("platinclude", vars={"installed_platbase": sys.argv[1]}))
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] 3+ messages in thread
* Re: [gentoo-dev] [PATCH] python-utils-r1.eclass: Redo cross-prefix support using sysconfig
2023-08-25 21:18 [gentoo-dev] [PATCH] python-utils-r1.eclass: Redo cross-prefix support using sysconfig James Le Cuirot
@ 2023-08-26 4:09 ` Michał Górny
2023-08-26 4:10 ` Michał Górny
0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2023-08-26 4:09 UTC (permalink / raw
To: gentoo-dev; +Cc: James Le Cuirot
On Fri, 2023-08-25 at 22:18 +0100, James Le Cuirot wrote:
> We recently supported cross-prefix by rewriting PYTHON_SITEDIR and
> PYTHON_INCLUDEDIR from BROOT to EPREFIX. We now know that you can get
> sysconfig to use EPREFIX in the first place, which is cleaner.
>
> Signed-off-by: James Le Cuirot <chewi@gentoo.org>
> ---
> eclass/python-utils-r1.eclass | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> index f9c6d161d3f3..bd30c1203180 100644
> --- a/eclass/python-utils-r1.eclass
> +++ b/eclass/python-utils-r1.eclass
> @@ -346,24 +346,22 @@ _python_export() {
> PYTHON_SITEDIR)
> [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
> PYTHON_SITEDIR=$(
> - "${PYTHON}" - <<-EOF || die
> - import sysconfig
> - print(sysconfig.get_path("purelib"))
> + "${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die
> + import sys, sysconfig
> + print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))
> EOF
> )
> - PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"}
> export PYTHON_SITEDIR
> debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
> ;;
> PYTHON_INCLUDEDIR)
> [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
> PYTHON_INCLUDEDIR=$(
> - "${PYTHON}" - <<-EOF || die
> - import sysconfig
> - print(sysconfig.get_path("platinclude"))
> + "${PYTHON}" - "${ESYSROOT}/usr" <<-EOF || die
> + import sys, sysconfig
> + print(sysconfig.get_path("platinclude", vars={"installed_platbase": sys.argv[1]}))
> EOF
> )
> - PYTHON_INCLUDEDIR=${ESYSROOT}${PYTHON_INCLUDEDIR#"${BROOT-${EPREFIX}}"}
> export PYTHON_INCLUDEDIR
> debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
>
I'm thinking we should probably set all base/prefix vars instead of
making assumptions which one will actually be used.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-dev] [PATCH] python-utils-r1.eclass: Redo cross-prefix support using sysconfig
2023-08-26 4:09 ` Michał Górny
@ 2023-08-26 4:10 ` Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2023-08-26 4:10 UTC (permalink / raw
To: gentoo-dev; +Cc: James Le Cuirot
On Sat, 2023-08-26 at 06:09 +0200, Michał Górny wrote:
> On Fri, 2023-08-25 at 22:18 +0100, James Le Cuirot wrote:
> > We recently supported cross-prefix by rewriting PYTHON_SITEDIR and
> > PYTHON_INCLUDEDIR from BROOT to EPREFIX. We now know that you can get
> > sysconfig to use EPREFIX in the first place, which is cleaner.
> >
> > Signed-off-by: James Le Cuirot <chewi@gentoo.org>
> > ---
> > eclass/python-utils-r1.eclass | 14 ++++++--------
> > 1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> > index f9c6d161d3f3..bd30c1203180 100644
> > --- a/eclass/python-utils-r1.eclass
> > +++ b/eclass/python-utils-r1.eclass
> > @@ -346,24 +346,22 @@ _python_export() {
> > PYTHON_SITEDIR)
> > [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
> > PYTHON_SITEDIR=$(
> > - "${PYTHON}" - <<-EOF || die
> > - import sysconfig
> > - print(sysconfig.get_path("purelib"))
> > + "${PYTHON}" - "${EPREFIX}/usr" <<-EOF || die
> > + import sys, sysconfig
> > + print(sysconfig.get_path("purelib", vars={"base": sys.argv[1]}))
> > EOF
> > )
> > - PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"}
> > export PYTHON_SITEDIR
> > debug-print "${FUNCNAME}: PYTHON_SITEDIR = ${PYTHON_SITEDIR}"
> > ;;
> > PYTHON_INCLUDEDIR)
> > [[ -n ${PYTHON} ]] || die "PYTHON needs to be set for ${var} to be exported, or requested before it"
> > PYTHON_INCLUDEDIR=$(
> > - "${PYTHON}" - <<-EOF || die
> > - import sysconfig
> > - print(sysconfig.get_path("platinclude"))
> > + "${PYTHON}" - "${ESYSROOT}/usr" <<-EOF || die
> > + import sys, sysconfig
> > + print(sysconfig.get_path("platinclude", vars={"installed_platbase": sys.argv[1]}))
> > EOF
> > )
> > - PYTHON_INCLUDEDIR=${ESYSROOT}${PYTHON_INCLUDEDIR#"${BROOT-${EPREFIX}}"}
> > export PYTHON_INCLUDEDIR
> > debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"
> >
>
> I'm thinking we should probably set all base/prefix vars instead of
> making assumptions which one will actually be used.
Actually, nevermind. I see that installer/gpep517 is doing the same,
and overriding all variables there would have adverse effects, so let's
keep it to one variable for consistency.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-26 4:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-25 21:18 [gentoo-dev] [PATCH] python-utils-r1.eclass: Redo cross-prefix support using sysconfig James Le Cuirot
2023-08-26 4:09 ` Michał Górny
2023-08-26 4:10 ` 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