commit:     4a70a7bcd62e6ad338e150c9d072c2c614fe22a2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  7 14:36:25 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Jun  7 14:37:53 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4a70a7bc

distutils-r1.eclass: Revert "Move venv/merge-root logic to post-phases"

Reverts: de2e1bee2462fccc445b845a889b006f888c6b1d
Closes: https://bugs.gentoo.org/850418
Closes: https://bugs.gentoo.org/850433
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass | 124 +++++++++++++++++++--------------------------
 1 file changed, 51 insertions(+), 73 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index d3826cf99c9f..7829e521ca7b 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1370,7 +1370,33 @@ distutils-r1_python_compile() {
                addpredict /usr/lib/portage/pym
                addpredict /usr/local # bug 498232
 
-               distutils_pep517_install "${BUILD_DIR}/install"
+               local root=${BUILD_DIR}/install
+               distutils_pep517_install "${root}"
+
+               # 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 "${bindir}" || die
+               ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die
+               ln -s "${EPYTHON}" "${bindir}/python3" || die
+               ln -s "${EPYTHON}" "${bindir}/python" || die
+               cat > "${bindir}"/pyvenv.cfg <<-EOF || die
+                       include-system-site-packages = true
+               EOF
+
+               # we need to change shebangs to point to the venv-python
+               find "${bindir}" -type f -exec sed -i \
+                       -e 
"1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \
+                       {} + || die
        fi
 }
 
@@ -1484,7 +1510,18 @@ distutils-r1_python_install() {
        _python_check_EPYTHON
 
        local scriptdir=${EPREFIX}/usr/bin
-       if [[ ! ${DISTUTILS_USE_PEP517} ]]; then
+       if [[ ${DISTUTILS_USE_PEP517} ]]; then
+               local root=${BUILD_DIR}/install
+               # remove the altered bindir, executables from the package
+               # are already in scriptdir
+               rm -r "${root}${scriptdir}" || die
+               if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then
+                       local wrapped_scriptdir=${root}$(python_get_scriptdir)
+                       if [[ -d ${wrapped_scriptdir} ]]; then
+                               mv "${wrapped_scriptdir}" "${root}${scriptdir}" 
|| die
+                       fi
+               fi
+       else
                local root=${D%/}/_${EPYTHON}
                [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/}
 
@@ -1537,6 +1574,18 @@ distutils-r1_python_install() {
 
                esetup.py "${args[@]}"
        fi
+
+       if [[ ! ${DISTUTILS_SINGLE_IMPL} || ${DISTUTILS_USE_PEP517} ]]; then
+               multibuild_merge_root "${root}" "${D%/}"
+               if [[ ${DISTUTILS_USE_PEP517} ]]; then
+                       # we need to recompile everything here in order to embed
+                       # the correct paths
+                       python_optimize "${D%/}$(python_get_sitedir)"
+               fi
+       fi
+       if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+               _distutils-r1_wrap_scripts "${scriptdir}"
+       fi
 }
 
 # @FUNCTION: distutils-r1_python_install_all
@@ -1726,43 +1775,6 @@ distutils-r1_src_configure() {
        return ${ret}
 }
 
-# @FUNCTION: _distutils-r1_post_python_compile
-# @INTERNAL
-# @DESCRIPTION:
-# Post-phase function called after python_compile.  In PEP517 mode,
-# it adjusts the install tree for venv-style usage.
-_distutils-r1_post_python_compile() {
-       debug-print-function ${FUNCNAME} "${@}"
-
-       local root=${BUILD_DIR}/install
-       if [[ ${DISTUTILS_USE_PEP517} && -d ${root} ]]; then
-               # 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 "${bindir}" || die
-               ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die
-               ln -s "${EPYTHON}" "${bindir}/python3" || die
-               ln -s "${EPYTHON}" "${bindir}/python" || die
-               cat > "${bindir}"/pyvenv.cfg <<-EOF || die
-                       include-system-site-packages = true
-               EOF
-
-               # we need to change shebangs to point to the venv-python
-               find "${bindir}" -type f -exec sed -i \
-                       -e 
"1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \
-                       {} + || die
-       fi
-}
-
 distutils-r1_src_compile() {
        debug-print-function ${FUNCNAME} "${@}"
        local ret=0
@@ -1828,40 +1840,6 @@ distutils-r1_src_test() {
 _distutils-r1_post_python_install() {
        debug-print-function ${FUNCNAME} "${@}"
 
-       local root=${D%/}/_${EPYTHON}
-       [[ ${DISTUTILS_USE_PEP517} ]] && root=${BUILD_DIR}/install
-       local scriptdir=${EPREFIX}/usr/bin
-       if [[ -d ${root} && ${DISTUTILS_USE_PEP517} ]]; then
-               # remove the altered bindir, executables from the package
-               # are already in scriptdir
-               rm -r "${root}${scriptdir}" || die
-               if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then
-                       local wrapped_scriptdir=${root}$(python_get_scriptdir)
-                       if [[ -d ${wrapped_scriptdir} ]]; then
-                               mv "${wrapped_scriptdir}" "${root}${scriptdir}" 
|| die
-                       fi
-               fi
-
-               # prune empty directories to see if ${root} contains anything
-               # to merge
-               find "${BUILD_DIR}"/install -type d -empty -delete || die
-       fi
-
-       if [[ -d ${root} ]]; then
-               if [[ ! ${DISTUTILS_SINGLE_IMPL} || ${DISTUTILS_USE_PEP517} ]]; 
then
-                       multibuild_merge_root "${root}" "${D%/}"
-               fi
-       fi
-       local pypath=${D%/}$(python_get_sitedir)
-       if [[ ${DISTUTILS_USE_PEP517} && -d ${pypath} ]]; then
-               # we need to recompile everything here in order to embed
-               # the correct paths
-               python_optimize "${pypath}"
-       fi
-       if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
-               _distutils-r1_wrap_scripts "${scriptdir}"
-       fi
-
        local forbidden_package_names=(
                examples test tests
                .pytest_cache .hypothesis _trial_temp

Reply via email to