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

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Fri Jan 14 16:20:03 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 | 381 ++++++++++++++++++++++++++++---------
    1 file changed, 291 insertions(+), 90 deletions(-)

    Changes:

    * do not override build paths as pep517 doesn't respect pydistutils.cfg
    and this effectively means it can't find built extensions and builds
    them again

    * fix handling legacy packages with pyproject.toml that don't declare
    build-backend

    * add more backends (fdm, poetry)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index ba0226f8fed3..eb8471db8a53 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -78,7 +78,35 @@ 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