• [gentoo-dev] [PATCH] python-utils-r1.eclass: Fix PYTHON_SITEDIR/INCLUDE

    From James Le Cuirot@21:1/5 to All on Wed Aug 16 00:10:02 2023
    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..68b28c0ed806 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

    --- SoupGate-Win32 v1.05
    * Origi
  • From Ionen Wolkens@21:1/5 to James Le Cuirot on Wed Aug 16 00:30:01 2023
    On Tue, Aug 15, 2023 at 11:02:54PM +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..68b28c0ed806 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}}}

    For a minor nitpick, should use quotes for the substitution, aka:

    PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"}

    Or else if BROOT/EPREFIX somehow had glob characters in them, they will actually be globbing.

    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}}}

    Same here.

    export PYTHON_INCLUDEDIR
    debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"

    --
    2.41.0


    --
    ionen

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmTb+1AACgkQskQGsLCs QzTl0Af+KykktYs8QM5IjGeBB4wcRbo758CkUd+DKR2cdn1P205PazuGNbRuBilN vp+hLi07kSsvgBH3SLfJUlcrjLIJdjbTGHD9AkaJ4LqPuZJ5l8ncAyHU+2lqHR7G yu6EMA2Ci/i+sHDcZasjR+82taV6GMW5+p8QS7l/AHann4of7MVJuPyPqBvlk2HS MEQskEOiwTf2gCQbQXR+BV39y44UX84BQ96tgm3ncM20TuNGtCLDNBA8RT59In5k KzObO6HktFiwbYhyw3BmOaMnt7RBLUnWZc9zIfEj54YtnGfjnJ2jhgpN/BK/peeD RHn0BKR2IJLmc7U2pxGPDwQuG8zFlA==
    =6Jya
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Le Cuirot@21:1/5 to Ionen Wolkens on Wed Aug 16 08:40:01 2023
    On Tue, 2023-08-15 at 18:25 -0400, Ionen Wolkens wrote:
    On Tue, Aug 15, 2023 at 11:02:54PM +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..68b28c0ed806 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}}}

    For a minor nitpick, should use quotes for the substitution, aka:

    PYTHON_SITEDIR=${EPREFIX}${PYTHON_SITEDIR#"${BROOT-${EPREFIX}}"}

    Or else if BROOT/EPREFIX somehow had glob characters in them, they will actually be globbing.

    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}}}

    Same here.

    export PYTHON_INCLUDEDIR
    debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = ${PYTHON_INCLUDEDIR}"

    --
    2.41.0


    Oops, not like me to miss that. Thanks!

    -----BEGIN PGP SIGNATURE-----

    iQJFBAABCAAvFiEEPxcZ3tkwcedKm2a8EiZBXQDdMTcFAmTcbo8RHGNoZXdpQGdl bnRvby5vcmcACgkQEiZBXQDdMTc8JRAAm8+Jsq5Tvt0C2cu8hNVOOgy0K3C5YpaD j7ASkuUoYzy43RlG74SCvMA/HmozfGBsR7nB70Zdp32wIzUGbfQoG7Kohv8z9ONr ZkA20PEiIrEfLgzjP93y27igTgrDHA//2X4FS9syKGj+J5Jd+gPWpshfYsq2Wuuw gbNYYvtxggYua7dOtjEHKP2dhATiiF0HfCocjHM2QsbHQTrHYAKcHL5epo4gRbhx D1lGJmnLG8BDwOvqn2xadoD7hTi6h26L/ie7qmw7wRHXfGQPMoAD33BWsFOJNM9y /6DFiOHTxsxJHl75bLFqZiXAinP5NUuvaw3aCqTpjbHZIZmaGyA+Opu5eGUUgQHz IkIeo7qiTFbXjDv8tyhwityrWHTH0Tzkcm5FgSTHEjRepNCeIgDVCBH96YJzGfiU VtPc2fGVxsHLhWDpnqNqId6n9hATDtN0Sea5TJl+XNHsFHkxySvYnCNx/nf+bLcB VSNreLR2hHSPxRGP58XArdMZwrN55zHXlyLfskCKDw4EH1ZnGjjCASfHt0NdoLGV W4F3M77oyDrCUb34y55cWagKTPdqkPmH9WAat8q/zi782dVZ4s19HK+ypccsYq8d Ql49/0iIQMm63FOZdHRCOrMYbGzWrDof49t0JIeI3W16XQicEMgMtHypAKcsD3O2
    7cisTiB+8os=
    =kRtk
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)