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

    From James Le Cuirot@21:1/5 to All on Wed Aug 16 08:50:01 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..abfb74832f30 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
    * O
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to James Le Cuirot on Wed Aug 16 12:50:01 2023
    On Wed, 2023-08-16 at 07:39 +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..abfb74832f30 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}"



    You don't seem to have changed that, actually.

    --
    Best regards,
    Michał Górny

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Le Cuirot@21:1/5 to All on Wed Aug 16 14:20:02 2023
    On Wed, 2023-08-16 at 12:47 +0200, Michał Górny wrote:
    On Wed, 2023-08-16 at 07:39 +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..abfb74832f30 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}"



    You don't seem to have changed that, actually.

    Ah! Sorry, I shouldn't make changes in a rush before starting the day job. ionen said globbing, when this is technically pattern matching, so I got confused and thought quoting the whole thing would fix it. Actually globbing doesn't even occur when assigning variables.

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

    iQJFBAABCAAvFiEEPxcZ3tkwcedKm2a8EiZBXQDdMTcFAmTcvT8RHGNoZXdpQGdl bnRvby5vcmcACgkQEiZBXQDdMTekEhAAlB7WvDgxR/l4ElbBEWVGnaJdJ96JmMjW 252EMdcFREzYMgWcLEPSVyrTgQY+Py/ZkmbVvX++piXDfmXyBSmI7VNshvUwk+du oeywMcCaMALksXw+PxUPZSML+0jHQqzH84mdxWVMAY25H0UHBvmG/+FmE6tAlPhy QBprXiMMk4iiwkPm/llr0SQpzAqoaksPKcESp8Ws6gC3q3SufHAT7QJDsGJABT7d EUal/K7SG/UayRSJ4H2rPZyDEe4bW+FVYtvB7rNwYxOHS4NkZ4tN9r+Q1qVgimY8 bpqyVPvTwhqEIC3aN31p7s+PmUf7gMP2G/FVSo6KfP9xkfMrc/WxjVHx92UU7e3l 7Gtj/7YVEONjdiquNp9GMe+nTjhtoTDbBrgLAQoaVf/y8qzIOYgdQtS8ZQNYS9EX PdA78pTa8TodZXl5C0NAzTEhGAIWK/k5qp1/NyVI7lupG3paxTjBZcvypoaB0knx 57yY7bDVLkNhRwHfLriz9W8ekncpLgt1cddLJgR2eqMRyWypwoEwc5XVLrlqAQaM 5s78GDL4PptkYbylzDMi4Pvu3W/uZEFmxzUMFLHxTIA9P2vt38AjuwjLjAO0qCVR 5lIBKKm7tLjmfeZ5PoQ13X0FFTBBvcot4P8sg7g2J/3DcYd782gJ32Bwe3j4801z
    Xdcilj8rIDg=
    =P2JN
    -----END PGP SIGNATURE-----

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