• [gentoo-dev] [PATCH 1/2] distutils-r1.eclass: Set script shebangs to ve

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Jan 26 15:20:01 2022
    Alter the shebangs of generated scripts to point out the to venv Python executables in PEP 517 mode. Otherwise, the executables are run with
    system Python during the test run and therefore do not use the venv.

    For convenience, rather than modifying them back just copy them
    immediately into the python-exec directory. This means that instead of reverting some of our python_compile() changes in python_install()
    and then moving scripts to the python-exec directory, we can just
    discard /usr/bin and let the wrapping logic recreate it.

    While at it, stop repeating ${root}${EPREFIX}/usr/bin multiple times
    in python_compile(). Just shove it into a helper variable. Also move pyvenv.cfg inside bindir for convenience — Python is fine with either location.

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

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index 9b2dc841054c..cf3eb639d5e6 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -982,14 +982,30 @@ distutils-r1_python_compile() {
    esetup.py clean -a
    fi

    + # copy executables to python-exec directory
    + # we do it early so that we can alter bindir recklessly
    + local bindir=${root}${EPREFIX}/usr/bin
    + local rscriptdir=${root}$(python_get_scriptdir)
    + [[ -d ${rscriptdir} ]] &&
    + die "${rscriptdir} should not exist!"
    + if [[ -d ${bindir} ]]; then
    + mkdir -p "${rscriptdir}" || die
    + cp -a --reflink=auto "${bindir}"/. "${rscriptdir}"/ || die
    + fi
    +
    # enable venv magic inside the install tree
    - mkdir -p "${root}${EPREFIX}"/usr/bin || die
    - ln -s "${PYTHON}" "${root}${EPREFIX}/usr/bin/${EPYTHON}" || die - ln -s "${EPYTHON}" "${root}${EPREFIX}/u
  • From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Wed Jan 26 15:20:01 2022
    Add an einfo message for calling installer. Indent both messages
    relevant to PEP 517 logic.

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

    diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
    index cf3eb639d5e6..7dfd92691b59 100644
    --- a/eclass/distutils-r1.eclass
    +++ b/eclass/distutils-r1.eclass
    @@ -952,7 +952,7 @@ distutils-r1_python_compile() {
    fi
    fi

    - einfo "Building a wheel via ${build_backend}"
    + einfo " Building the wheel via ${build_backend}"
    "${EPYTHON}" -c "import ${build_backend%:*}; \
    import os; \
    ${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR'])" ||
    @@ -964,6 +964,7 @@ distutils-r1_python_compile() {
    fi

    local root=${BUILD_DIR}/install
    + einfo " Installing the wheel to ${root}"
    # NB: --compile-bytecode does not produce the correct paths,
    # and python_optimize doesn't handle being called outside D,
    # so we just defer compiling until the final merge
    --
    2.35.0

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