summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-06-07 16:36:25 +0200
committerMichał Górny <mgorny@gentoo.org>2022-06-07 16:37:53 +0200
commit4a70a7bcd62e6ad338e150c9d072c2c614fe22a2 (patch)
treee043172ed465dc080396993979813b29b3641bcf /eclass
parentdistutils-r1.eclass: Revert "Introduce DISTUTILS_USE_PEP517=no mode" (diff)
downloadgentoo-4a70a7bcd62e6ad338e150c9d072c2c614fe22a2.tar.gz
gentoo-4a70a7bcd62e6ad338e150c9d072c2c614fe22a2.tar.bz2
gentoo-4a70a7bcd62e6ad338e150c9d072c2c614fe22a2.zip
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@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/distutils-r1.eclass124
1 files 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