• [gentoo-dev] [PATCH] distutils-r1.eclass: Implement PEP517 mode

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu Jan 13 18:50:01 2022
    Add a PEP517 mode to the distutils-r1.eclass in order to facilitate
    building packages via PEP517 backends. In order to use it, set DISTUTILS_USE_PEP517 to the appropriate build system name. The eclass
    will take care of setting BDEPEND, then invoke the backend to build
    a wheel and then install its contents in python_compile(). The install
    phase is limited to merging the staging area into the image directory.

    In PEP517 mode, the test phase is automatically provided with venv-style install tree that should suffice the vast majority of test suites.
    As a result, distutils_install_for_testing should no longer be necessary
    and is not available in this mode.

    The new mode can also be used to install pre-PEP517 distutils
    and setuptools packages. To do so, just specify setuptools backend.
    If pyproject.toml is missing, the eclass assumes legacy setuptools
    backend that invokes setup.py. It also enables setuptools-vendored
    distutils, effectively carrying the migration from deprecated stdlib
    version.

    The PEP517 support effectively deprecates the legacy eclass mode.
    This follows upstream deprecation of distutils and install commands
    in setuptools.

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


    For a few examples of packages using the new mode, please see: https://github.com/gentoo/gentoo/pull/23721

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index ba0226f8fed3..5c1a07d22d21 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -78,7 +78,33 @@ esac
    # to be exported. It must be run in order for the eclass functions
    # to function properly.

    +# @ECLASS-VARIABLE: DISTUTILS_USE_PEP517
    +# @PRE_INHERIT
    +# @DEFAULT_UNSET
    +# @DESCRIPTION:
    +# Enable experimental PEP 517 mode for the specified build system.
    +# In this mode, the complete build and install is done
    +# in python_compile(), venv-style install tree is provided
    +# to python_test() and python_install() just merges the temporary
    +# install tree into real fs.
    +#
    +# The variable specifies the build system used. Currently,
    +# the following values are
  • From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to All on Thu Jan 13 18:50:01 2022
    On Thu, 2022-01-13 at 18:42 +0100, Michał Górny wrote:
    For a few examples of packages using the new mode, please see: https://github.com/gentoo/gentoo/pull/23721

    I'm sorry, wrong link. It should be:

    https://github.com/gentoo/gentoo/pull/23750

    --
    Best regards,
    Michał Górny

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