• [gentoo-dev] [PATCH 0/6] Another batch of distutils-r1.eclass fixes

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Feb 1 00:00:01 2022
    Hi,

    This series includes some long overdue fixes + some recent PEP517 fixes.
    In order:

    1. Disabling post-test egg-info cleaning code in PEP517 -- this was
    needed when distutils_install_for_testing was used, and we no longer
    use it in PEP517 mode.

    2. Fix a regression that `esetup.py` would successfully do nothing
    when run in a directory where there's no setuptools config. Now it
    requires the current directory to contain either `setup.py`
    or `setup.cfg`.

    3. Make distutils sub-phases pass the return value through. This
    primarily fixes a somewhat rare bug involving:

    src_test() {
    virtx distutils-r1_src_test
    }

    python_test() {
    epytest
    }

    This code would not die on failure because virtx runs its arguments
    nonfatal, and epytest respects nonfatal. Ideally, you'd use explicit
    `|| die` in python_test() but if you don't, the unsuccessful return
    code from epytest will eventually reach virtx and cause it to fail.

    4. Refactoring.

    5. Add DISTUTILS_DEPS containing BDEPEND in PEP517 mode. This is needed
    to populate BDEPEND in DISTUTILS_OPTIONAL ebuilds. For non-PEP517
    mode, we assumed that the dev will just inline the setuptools dep
    but with PEP517 we have more deps, and the tools used by eclass
    (tomli, installer) are not guaranteed to be fixed forever.

    6. Add a QA warning when you declare DISTUTILS_USE_SETUPTOOLS along
    with DISTUTILS_OPTIONAL (it doesn't work). This warning was
    originally part of the mismatched DUS check and was removed along
    with it. However, this one still makes sense, so let's do it
    in the eclass.

    Michał Górny (6):
    distutils-r1.eclass: Disable stale egg-info cleaning in PEP517 mode
    distutils-r1.eclass: make esetup.py require setup.{py,cfg}
    distutils-r1.eclass: Fix subphase return value passthrough
    distutils-r1.eclass: Move DISTUTILS_OPTIONAL check into set_globals
    distutils-r1.eclass: Add DISTUTILS_DEPS output var for PEP 517 mode
    distutils-r1.eclass: Restore QA warning for DUS + DISTUTILS_OPTIONAL

    eclass/distutils-r1.eclass | 114 +++++++++++++++++++++++++++++--------
    1 file changed, 90 insertions(+), 24 deletions(-)

    --
    2.35.1

    --- 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 Feb 1 00:10:01 2022
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    ---
    eclass/distutils-r1.eclass | 16 +++++++++-------
    1 file changed, 9 insertions(+), 7 deletions(-)

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 8942a6149c93..4a9fdb4018b4 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -213,15 +213,17 @@ _distutils_set_globals() {
    [[ -n ${rdep} ]] && rdep="$(python_gen_cond_dep "${rdep}")"
    fi

    - RDEPEND="${PYTHON_DEPS} ${rdep}"
    - if [[ ${EAPI} != 6 ]]; then
    - BDEPEND="${PYTHON_DEPS} ${bdep}"
    - else
    - DEPEND="${PYTHON_DEPS} ${bdep}"
    + if [[ ! ${DISTUTILS_OPTIONAL} ]]; then
    + RDEPEND="${PYTHON_DEPS} ${rdep}"
    + if [[ ${EAPI} != 6 ]]; then
    + BDEPEND="${PYTHON_DEPS} ${bdep}"
    + else
    + DEPEND="${PYTHON_DEPS} ${bdep}"
    + fi
    + REQUIRED_USE=${PYTHON_REQUIRED_USE}
    fi
    - REQUIRED_USE=${PYTHON_REQUIRED_USE}
    }
    -[[ ! ${DISTUTILS_OPTIONAL} ]] && _distutils_set_globals +_distutils_set_globals
    unset -f _distutils_set_globals

    # @ECLASS-VARIABLE: PATCHES
    --
    2.35.1

    --- SoupGate-
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Tue Feb 1 00:10:01 2022
    Make esetup.py fail if neither setup.py nor setup.cfg is available.
    To support PEP 517 builds, the function has been modified to work
    without setup.py. However, this also caused esetup.py to implicitly
    succeed in installing zero files on non-distutils/setuptools packages.

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

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 4ec252958408..a81d95f4eb6e 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -544,6 +544,9 @@ esetup.py() {
    if [[ ${DISTUTILS_USE_SETUPTOOLS} == pyproject.toml ]]; then
    setup_py=( -m pyproject2setuppy )
    elif [[ ! -f setup.py ]]; then
    + if [[ ! -f setup.cfg ]]; then
    + die "${FUNCNAME}: setup.py nor setup.cfg not found"
    + fi
    setup_py=( -c "from setuptools import setup; setup()" )
    fi

    --
    2.35.1

    --- 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 Feb 1 00:10:02 2022
    Fix distutils-r1 phase functions to correctly pass through the return
    value from the subphases. This fixes e.g. the mistake of virtx
    not failing in the following case:

    src_test() {
    virtx distutils-r1_src_test
    }

    python_test() {
    epytest
    }

    This is because virtx implicitly uses nonfatal and epytest uses
    `die -n`. However, since the return value was not passed through, virtx
    never knew that anything has failed.

    While this covers only trivial cases and this is better solved via dying explicitly in the redefined python_test(), there's no harm in adding
    this passthrough.

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

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index a81d95f4eb6e..8942a6149c93 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -1319,8 +1319,10 @@ distutils-r1_run_phase() {
    local -x LDSHARED="${CC} ${ldopts}" LDCXXSHARED="${CXX} ${ldopts}"

    "${@}"
    + local ret=${?}

    cd "${_DISTUTILS_INITIAL_CWD}" || die
    + return "${ret}"
    }

    # @FUNCTION: _distutils-r1_run_common_phase
    @@ -1378,14 +1380,14 @@ _distutils-r1_run_foreach_impl() {

    distutils-r1_src_prepare() {
    debug-print-function ${FUNCNAME} "${@}"
    -
    + local ret=0
    local _DISTUTILS_DEFAULT_CALLED

    # common preparations
    if declare -f python_prepare_all >/dev/null; then
    - python_prepare_all
    + python_prepare_all || ret=${?}
    else
    - distutils-r1_python_prepare_all
    + distutils-r1_python_prepare_all || ret=${?}
    fi

    if [[ ! ${_DISTUTIL