• Re: [gentoo-dev] [PATCH] meson.eclass: setup python binaries if python

    From Ionen Wolkens@21:1/5 to Eli Schwartz on Thu May 22 07:10:01 2025
    On Thu, May 22, 2025 at 12:35:48AM -0400, Eli Schwartz wrote:
    This has been bothering me for a while. Meson will detect find_program('python3') as the dummy shim in ${T} defined by the eclass,
    and py.find_installation() may be the python that *Meson* was built
    with. In DISTUTILS_USE_PEP517=meson-python a dedicated machine file is created by the build backend but we should set this for other types of packages as well.

    Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
    ---
    eclass/meson.eclass | 11 ++++++++++-
    1 file changed, 10 insertions(+), 1 deletion(-)

    diff --git a/eclass/meson.eclass b/eclass/meson.eclass
    index a2bc5537e458..ab82234942d5 100644
    --- a/eclass/meson.eclass
    +++ b/eclass/meson.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2017-2024 Gentoo Authors
    +# Copyright 2017-2025 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: meson.eclass
    @@ -224,7 +224,16 @@ _meson_create_native_file() {
    pkg-config = '$(tc-getBUILD_PKG_CONFIG)'
    strip = $(_meson_env_array "$(tc-getBUILD_STRIP)")
    windres = $(_meson_env_array "$(tc-getBUILD_PROG RC windres)")
    + EOF
    +
    + if [[ -n ${EPYTHON} ]]; then
    + cat >> "${fn}" <<-EOF
    + python = '${EPREFIX}/usr/bin/${EPYTHON}'
    + python3 = '${EPREFIX}/usr/bin/${EPYTHON}'
    + EOF
    + fi

    One problem is that there is two potential usecase here.

    1. build system storing path for runtime use (rare'ish)
    2. using at build time for some script (more common)

    1 should indeed be ${EPREFIX}/usr/bin/${EPYTHON}
    2 should be either the wrapper or ${PYTHON} which includes BROOT

    So I think this breaks ROOT builds unless I'm missing something.


    + cat >> "${fn}" <<-EOF
    [built-in options]
    c_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_CPPFLAGS}")
    c_link_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_LDFLAGS}")
    --
    2.49.0



    --
    ionen

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

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmgusTYACgkQskQGsLCs QzRvMQf/ROB6GeTag2JpcgL6mNpbpvtKRmUr2Oh7H8RxzODSb/s6Ri0a74QlZ2yP Z9TPfl2Y7Voky4CR1cHWhaC28UP4c6mkaLztCDMnoldDWTneT1B+lPXpxe6qSfHE PIiEk6VN8Q1nAZEM5BXo/or91VrdPwbOnLwOtrE+pDpDKSq7DFe3vsnwnVO9yFTd JpA1agshZOfUtrUndAwME5IHJBKUI9grG9XkVpc9qestzJuBXCKfWGf+82ulF7Dc OFJ5hd0D1A06gn//VT5JFQYebiWANzb4P1StWVwI6e7aUeFA43E66F2BXI4O04Dm XXk4hX4m5Ag0W0Nc1S/jlEXExnpMHg==
    =JfZf
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Ionen Wolkens on Thu May 22 08:00:01 2025
    On Thu, May 22, 2025 at 01:08:07AM -0400, Ionen Wolkens wrote:
    On Thu, May 22, 2025 at 12:35:48AM -0400, Eli Schwartz wrote:
    This has been bothering me for a while. Meson will detect find_program('python3') as the dummy shim in ${T} defined by the eclass, and py.find_installation() may be the python that *Meson* was built
    with. In DISTUTILS_USE_PEP517=meson-python a dedicated machine file is created by the build backend but we should set this for other types of packages as well.

    Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
    ---
    eclass/meson.eclass | 11 ++++++++++-
    1 file changed, 10 insertions(+), 1 deletion(-)

    diff --git a/eclass/meson.eclass b/eclass/meson.eclass
    index a2bc5537e458..ab82234942d5 100644
    --- a/eclass/meson.eclass
    +++ b/eclass/meson.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2017-2024 Gentoo Authors
    +# Copyright 2017-2025 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: meson.eclass
    @@ -224,7 +224,16 @@ _meson_create_native_file() {
    pkg-config = '$(tc-getBUILD_PKG_CONFIG)'
    strip = $(_meson_env_array "$(tc-getBUILD_STRIP)")
    windres = $(_meson_env_array "$(tc-getBUILD_PROG RC windres)")
    + EOF
    +
    + if [[ -n ${EPYTHON} ]]; then
    + cat >> "${fn}" <<-EOF
    + python = '${EPREFIX}/usr/bin/${EPYTHON}'
    + python3 = '${EPREFIX}/usr/bin/${EPYTHON}'
    + EOF
    + fi

    One problem is that there is two potential usecase here.

    1. build system storing path for runtime use (rare'ish)
    2. using at build time for some script (more common)

    1 should indeed be ${EPREFIX}/usr/bin/${EPYTHON}
    2 should be either the wrapper or ${PYTHON} which includes BROOT

    To add to this, guess we "could" use ${PYTHON} here as it'll be right
    when ROOT is unset and not break build-time usage for crossdev, but
    feel that just makes wrong-runtime-path issues harder to notice (vs
    the ${T} one) given we'll only spot issues with ROOT.

    tl;dr think the current situation is better even if means needing
    ebuild workarounds for #1.


    So I think this breaks ROOT builds unless I'm missing something.


    + cat >> "${fn}" <<-EOF
    [built-in options]
    c_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_CPPFLAGS}")
    c_link_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_LDFLAGS}")
    --
    2.49.0



    --
    ionen



    --
    ionen

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

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmguvKQACgkQskQGsLCs QzQnQQf5AX5ELkkwKh/AH52HtEBaep+C/wt7pvGf2tbpfOblU9DHk24fs8nZFVM/ duFiGrIUrT+Xndlz/9uRWvkAZfum31ftVbkahByUrRD/ovgWCK42By9wMrQ84pDW iKZYS+UU2CK5vFQ1d+oIz2ICaJWtjk/JgY4oGATHlwVTWs/9/MkKJ5mW+C+p74Qi Ia6fxk1pBvZRBxY3IGqEFBfotGYN40YEWbyD7T9s4byuAtnyW7h8k6QQiX6hyC1J Dy/ZmXSpY8IuZ0VX88mJJPHYgHnXEolSjFSWtQL8zs08Oxo1xnQh/tcc9ai0CSJ1 3OEDB4qVZOEIU5JPEeaGdYi2usHzPA==
    =fMHD
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Le Cuirot@21:1/5 to Eli Schwartz on Thu May 22 22:50:01 2025
    On Thu, 2025-05-22 at 00:35 -0400, Eli Schwartz wrote:
    This has been bothering me for a while. Meson will detect find_program('python3') as the dummy shim in ${T} defined by the eclass,
    and py.find_installation() may be the python that *Meson* was built
    with. In DISTUTILS_USE_PEP517=meson-python a dedicated machine file is created by the build backend but we should set this for other types of packages as well.

    Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
    ---
    eclass/meson.eclass | 11 ++++++++++-
    1 file changed, 10 insertions(+), 1 deletion(-)

    diff --git a/eclass/meson.eclass b/eclass/meson.eclass
    index a2bc5537e458..ab82234942d5 100644
    --- a/eclass/meson.eclass
    +++ b/eclass/meson.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 2017-2024 Gentoo Authors
    +# Copyright 2017-2025 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: meson.eclass
    @@ -224,7 +224,16 @@ _meson_create_native_file() {
    pkg-config = '$(tc-getBUILD_PKG_CONFIG)'
    strip = $(_meson_env_array "$(tc-getBUILD_STRIP)")
    windres = $(_meson_env_array "$(tc-getBUILD_PROG RC windres)")
    + EOF
    +
    + if [[ -n ${EPYTHON} ]]; then
    + cat >> "${fn}" <<-EOF
    + python = '${EPREFIX}/usr/bin/${EPYTHON}'
    + python3 = '${EPREFIX}/usr/bin/${EPYTHON}'
    + EOF
    + fi

    + cat >> "${fn}" <<-EOF
    [built-in options]
    c_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_CPPFLAGS}")
    c_link_args = $(_meson_env_array "${BUILD_CFLAGS} ${BUILD_LDFLAGS}")

    Is this not what https://github.com/mesonbuild/meson/pull/12116 deals with? I've been waiting *very* patiently.

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

    iQJFBAABCAAvFiEEPxcZ3tkwcedKm2a8EiZBXQDdMTcFAmgvjIkRHGNoZXdpQGdl bnRvby5vcmcACgkQEiZBXQDdMTfw2A//dvyeiEMrzNFGR8qzKuun4kwL0iRRmkCM 9xmJJ63p3vlEqhYrqsR5m1xqHy3g3lX81ZxN0sf1gsXL3xfmfFyZZjFiJ2MR/tBi VUS5xJQtx3W3X44DMoRVAQvAWV5iNlSmI6NAKRtrEosTMrq5qNdGYQpBBjd7KF1e aNP6XWHREVApSqKla6qJ6TH8yCNWB2cIImUUXLzPKWgCcDh0S4jCkmxS3ZMU6Pgg TjSbZxf2OR3yzrnCqCvVoVyynJlePiNdfKxd23MFeQldGjOff4KTG4rb64t5fgzb IZEECqVjgcSOzixDGz/1ayHUyWglN+9nye8thO+dZMW7rHODuXUxlsIpkLQzNNdt lXTYl6z1AcXVFDo/FlzFGzfWICKxT9bqxvKb2Q+AQxPevZMFj26JW6PtIQzVujGC qIzC/i2g4Zh3feKIHQNI+mE2PVcBzmpYT8cFCPD5LDlff8yjfHGcAf8NjX/9S39/ K0zbDgZ2pHc4e9v1WVzNyUr8enx6VpksC89fJ1GNfCSQ1Wouyutyb+NkwGAk4RSW e/XiVyzURPNCahNCRQVcn9PoTurXhx5HrdvVS8XCkW1dKbXhod5wkEGhgS9MVvrj miDX1alVDEmxJjqrQFtGwSrNNMb4Qkwzn864v0OAmZrhiEi04lV3A3734y0F/jOy
    jKhfZmplEUc=
    =aRKf
    -----END PGP SIGNATURE-----

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