• [gentoo-dev] [PATCH 00/11] distutils-r1.eclass: uv-build support, setup

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Mar 25 21:30:01 2025
    Hi,

    Here's another batch of patches to distutils-r1. Aside from some
    refactoring, it includes the following changes:

    1. Lower bounds for most of the build systems were bumped to the lowest
    stable versions in ::gentoo. This should match upstream requirements
    better, especially that a few backends have recently added support
    for license expressions, and poetry-core gained PEP 621 metadata
    support.

    2. FLIT_ALLOW_INVALID is now set to avoid breakage when license
    validation fails.

    3. Support for uv-build backend is added. We hack the package a fair
    bit, because we don't want to waste time building another uv-build
    executable that's roughly 50% of dev-python/uv.

    4. We use unique build directories for each setuptools invocation now.
    This avoids issues when a single package is building more than one
    wheel, and they'd end up all copying files to the same build
    directory, and setuptools will just keep copying modules from one
    package to the next...

    5. We now make it easier to override the PEP517 backend used. You set
    DISTUTILS_UPSTREAM_PEP517 to the backend used upstream, and
    DISTUTILS_USE_PEP517 to the backend you want to use -- and you don't
    have to edit build-backend in pyproject.toml anymore. Most packages
    won't need it, and should just continue setting DISTUTILS_USE_PEP517.

    --
    Best regards,
    Michał Górny

    Michał Górny (11):
    distutils-r1.eclass: Bump build system lower bounds
    distutils-r1.eclass: Set FLIT_ALLOW_INVALID
    dev-python/uv-build: New package, v0.6.9
    distutils-r1.eclass: Support uv-build backend
    distutils-r1.eclass: Support the legacy "uv" backend too
    distutils-r1.eclass: Use unique setuptools build directories
    distutils-r1.eclass: Reflow _distutils-r1_backend_to_key()
    distutils-r1.eclass: Invert DISTUTILS_USE_PEP517 - backend mapping
    distutils-r1.eclass: Support overriding PEP517 build backend
    dev-python/uv-build: Use DISTUTILS_UPSTREAM_PEP517
    distutils-r1.eclass: Reflow distutils-r1_python_compile()

    dev-python/uv-build/Manifest | 1 +
    .../files/uv-build-0.6.9-use-uv.patch | 18 ++
    dev-python/uv-build/metadata.xml | 11 +
    dev-python/uv-build/uv-build-0.6.9.ebuild | 41 +++
    eclass/distutils-r1.eclass | 304 ++++++++++--------
    5 files changed, 236 insertions(+), 139 deletions(-)
    create mode 100644 dev-python/uv-build/Manifest
    create mode 100644 dev-python/uv-build/files/uv-build-0.6.9-use-uv.patch
    create mode 100644 dev-python/uv-build/metadata.xml
    create mode 100644 dev-python/uv-build/uv-build-0.6.9.ebuild

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Mar 25 21:30:01 2025
    Add a dynamic component to the build directory used by setuptools,
    to enable calling distutils-r1_python_compile multiple times without
    having the builds share the same build directory (and therefore end up
    being combined).

    Closes: https://bugs.gentoo.org/951853
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 6 +++++-
    1 file changed, 5 insertions(+), 1 deletion(-)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 8fc9ec5f568b..02245424bff6 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -1490,11 +1490,15 @@ distutils-r1_python_compile() {
    *)
    # we do this for all build systems, since other backends
    # and custom hooks may wrap setuptools
    + #
    + # we are appending a dynamic component so that
    + # distutils-r1_python_compile can be called multiple
    + # times and don't end up combining resulting packages
    mkdir -p "${BUILD_DIR}" || die
    local -x DIST_EXTRA_CONFIG="${BUILD_DIR}/extra-setup.cfg"
    cat > "${DIST_EXTRA_CONFIG}" <<-EOF || die
    [build]
    - build_base = ${BUILD_DIR}/build
    + build_base = ${BUILD_DIR}/build${#DISTUTILS_WHEELS[@]}

    [build_ext]
    parallel = $(makeopts_jobs "${MAKEOPTS} ${*}")

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Mar 25 21:40:02 2025
    Add a DISTUTILS_UPSTREAM_PEP517 variable that drives the build backend
    check, and can be used to override it when it is desirable to override
    the backend used.

    Closes: https://bugs.gentoo.org/951944
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 30 ++++++++++++++++++++++--------
    1 file changed, 22 insertions(+), 8 deletions(-)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 0ab42eba1f24..be61c49a8255 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -153,6 +153,20 @@
    # files are found in ${BUILD_DIR}/install after python_install(), they
    # will be merged into ${D}.

    +# @ECLASS_VARIABLE: DISTUTILS_UPSTREAM_PEP517
    +# @DESCRIPTION:
    +# Specifies the PEP517 build backend used upstream. It is used
    +# by the eclass to verify the correctness of DISTUTILS_USE_PEP517,
    +# and matches DISTUTILS_USE_PEP517 by default. However, it can be
    +# overriden to workaround the eclass check, when it is desirable
    +# to build the wheel using other backend than the one used upstream.
    +#
    +# Please note that even in packages using PEP621 metadata, there can
    +# be subtle differences between the behavior of different PEP517 build
    +# backends, for example regarding find
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Mar 25 21:40:02 2025
    Invert the eclass logic to map DISTUTILS_USE_PEP517 values to backends
    rather than the other way around. This is in preparation for making
    it possible to override the backend used. One side effect of this
    is that in case of DISTUTILS_USE_PEP517 mismatch, we no longer provide
    the "correct" value, and only indicate the backend used upstream.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 122 +++++++++++++++++--------------------
    1 file changed, 56 insertions(+), 66 deletions(-)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 2eb6e3208082..0ab42eba1f24 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -1064,58 +1064,57 @@ _distutils-r1_copy_egg_info() {
    find -name '*.egg-info' -type d -exec cp -R -p {} "${BUILD_DIR}"/ ';' || die
    }

    -# @FUNCTION: _distutils-r1_backend_to_key
    -# @USAGE: <backend>
    +# @FUNCTION: _distutils-r1_key_to_backend
    +# @USAGE: <key>
    # @INTERNAL
    # @DESCRIPTION:
    -# Print the DISTUTILS_USE_PEP517 value corresponding to the backend
    -# passed as the only argument.
    -_distutils-r1_backend_to_key() {
    +# Print the backend corresponding to the DISTUTILS_USE_PEP517 value. +_distutils-r1_key_to_backend() {
    debug-print-function ${FUNCNAME} "$@"

    - local backend=${1}
    - case ${backend} in
    - flit_core.buildapi|flit.buildapi)
    - echo flit
    + local key=${1}
    + case $
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Mar 25 21:40:02 2025
    Reflow distutils-r1_python_compile() to remove duplicate conditions
    and improve readability.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 117 ++++++++++++++++++-------------------
    1 file changed, 56 insertions(+), 61 deletions(-)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index be61c49a8255..7a28644252ba 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -1484,71 +1484,66 @@ distutils-r1_python_compile() {

    _python_check_EPYTHON

    - case ${DISTUTILS_USE_PEP517:-unset} in
    - no)
    - return
    - ;;
    - unset)
    - # legacy mode
    - _distutils-r1_copy_egg_info
    - esetup.py build -j "$(makeopts_jobs "${MAKEOPTS} ${*}")" "${@}"
    - ;;
    - *)
    - # we do this for all build systems, since other backends
    - # and custom hooks may wrap setuptools
    - #
    - # we are appending a dynamic component so that
    - # distutils-r1_python_compile can be called multiple
    - # times and don't end up combining resulting packages
    - mkdir -p "${BUILD_DIR}" || die
    - local -x DIST_EXTRA_CONFIG="${BUILD_DIR}/extra-setup.cfg"
    - cat > "${DIST_EXTRA_CONFI
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Mar 26 12:40:01 2025
    Add a safety check to verify that distutils_wheel_install is being
    (usually indirectly) called in python_compile(), when using PEP517
    build. If it weren't, this usually indicates that
    distutils-r1_python_compile (or distutils_pep517_install) was not
    called.

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 7 +++++++
    1 file changed, 7 insertions(+)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 7a28644252ba..2f173b741896 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -1246,6 +1246,8 @@ distutils_wheel_install() {
    -o -path '*.dist-info/licenses' \
    -o -path '*.dist-info/zip-safe' \
    \) -delete || die
    +
    + _DISTUTILS_WHL_INSTALLED=1
    }

    # @VARIABLE: DISTUTILS_WHEEL_PATH
    @@ -2011,6 +2013,11 @@ _distutils-r1_compare_installed_files() {
    _distutils-r1_post_python_compile() {
    debug-print-function ${FUNCNAME} "$@"

    + if [[ ! ${_DISTUTILS_WHL_INSTALLED} && ${DISTUTILS_USE_PEP517:-no} != no ]]
    + then
    + die "No wheel installed in python_compile(), did you call distutils-r1_python_compile?"
    + fi
    +
    local root=${BUILD_DIR}/install
    if [[ ${DISTUTILS_USE_PEP517} && -d ${root} ]]; then
    # copy executables to python-exec directory

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (2