summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2022-06-07 19:00:40 +0200
committerFabian Groffen <grobian@gentoo.org>2022-06-07 19:00:40 +0200
commita7c1d9d5107cce52c19f638df5454ece9cbbcfa7 (patch)
tree23eb483178166802cc85abdc5e3804bbbb428e93 /eclass
parenteclass: sync with gx86 (diff)
downloadprefix-a7c1d9d5107cce52c19f638df5454ece9cbbcfa7.tar.gz
prefix-a7c1d9d5107cce52c19f638df5454ece9cbbcfa7.tar.bz2
prefix-a7c1d9d5107cce52c19f638df5454ece9cbbcfa7.zip
python-utils-r1.eclass: sync from latest gx86, unbreak python pkgs
Bug: https://bugs.gentoo.org/850406 Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/python-utils-r1.eclass55
1 files changed, 44 insertions, 11 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index b9102cd320..c50da71ac8 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -712,6 +712,9 @@ python_scriptinto() {
python_doexe() {
debug-print-function ${FUNCNAME} "${@}"
+ [[ ${EBUILD_PHASE} != install ]] &&
+ die "${FUNCNAME} can only be used in src_install"
+
local f
for f; do
python_newexe "${f}" "${f##*/}"
@@ -730,6 +733,8 @@ python_doexe() {
python_newexe() {
debug-print-function ${FUNCNAME} "${@}"
+ [[ ${EBUILD_PHASE} != install ]] &&
+ die "${FUNCNAME} can only be used in src_install"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
@@ -778,6 +783,9 @@ python_newexe() {
python_doscript() {
debug-print-function ${FUNCNAME} "${@}"
+ [[ ${EBUILD_PHASE} != install ]] &&
+ die "${FUNCNAME} can only be used in src_install"
+
local _PYTHON_REWRITE_SHEBANG=1
python_doexe "${@}"
}
@@ -802,6 +810,9 @@ python_doscript() {
python_newscript() {
debug-print-function ${FUNCNAME} "${@}"
+ [[ ${EBUILD_PHASE} != install ]] &&
+ die "${FUNCNAME} can only be used in src_install"
+
local _PYTHON_REWRITE_SHEBANG=1
python_newexe "${@}"
}
@@ -821,10 +832,10 @@ python_newscript() {
# site-packages directory.
#
# In the relative case, the exact path is determined directly
-# by each python_doscript/python_newscript function. Therefore,
-# python_moduleinto can be safely called before establishing the Python
-# interpreter and/or a single call can be used to set the path correctly
-# for multiple implementations, as can be seen in the following example.
+# by each python_domodule invocation. Therefore, python_moduleinto
+# can be safely called before establishing the Python interpreter and/or
+# a single call can be used to set the path correctly for multiple
+# implementations, as can be seen in the following example.
#
# Example:
# @CODE
@@ -848,6 +859,10 @@ python_moduleinto() {
# and packages (directories). All listed files will be installed
# for all enabled implementations, and compiled afterwards.
#
+# The files are installed into ${D} when run in src_install() phase.
+# Otherwise, they are installed into ${BUILD_DIR}/install location
+# that is suitable for picking up by distutils-r1 in PEP517 mode.
+#
# Example:
# @CODE
# src_install() {
@@ -870,13 +885,24 @@ python_domodule() {
d=${sitedir#${EPREFIX}}/${_PYTHON_MODULEROOT//.//}
fi
- (
- insopts -m 0644
- insinto "${d}"
- doins -r "${@}" || return ${?}
- )
-
- python_optimize "${ED%/}/${d}"
+ if [[ ${EBUILD_PHASE} == install ]]; then
+ (
+ insopts -m 0644
+ insinto "${d}"
+ doins -r "${@}" || return ${?}
+ )
+ python_optimize "${ED%/}/${d}"
+ elif [[ -n ${BUILD_DIR} ]]; then
+ local dest=${BUILD_DIR}/install${EPREFIX}/${d}
+ mkdir -p "${dest}" || die
+ cp -pR "${@}" "${dest}/" || die
+ (
+ cd "${dest}" &&
+ chmod -R a+rX "${@##*/}"
+ ) || die
+ else
+ die "${FUNCNAME} can only be used in src_install or with BUILD_DIR set"
+ fi
}
# @FUNCTION: python_doheader
@@ -895,6 +921,8 @@ python_domodule() {
python_doheader() {
debug-print-function ${FUNCNAME} "${@}"
+ [[ ${EBUILD_PHASE} != install ]] &&
+ die "${FUNCNAME} can only be used in src_install"
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
local includedir=$(python_get_includedir)
@@ -1334,6 +1362,11 @@ epytest() {
# remove common temporary directories left over by pytest plugins
rm -rf .hypothesis .pytest_cache || die
+ # pytest plugins create additional .pyc files while testing
+ # see e.g. https://bugs.gentoo.org/847235
+ if [[ -n ${BUILD_DIR} && -d ${BUILD_DIR} ]]; then
+ find "${BUILD_DIR}" -name '*-pytest-*.pyc' -delete || die
+ fi
return ${ret}
}