-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: python-utils-r1.eclass
# https://wiki.gentoo.org/wiki/Project:Python/python-utils-r1
case "${EAPI:-0}" in
- 0|1|2|3|4|5|6)
+ 0|1|2|3|4|5|6|7)
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
# 2) skip paths which do not exist
# (python2.6 complains about them verbosely)
- if [[ ${f} == /* && -d ${D}${f} ]]; then
- set -- "${D}${f}" "${@}"
+ if [[ ${f} == /* && -d ${D%/}${f} ]]; then
+ set -- "${D%/}${f}" "${@}"
fi
done < <("${PYTHON}" -c 'import sys; print("\0".join(sys.path))' || die)
local d
for d; do
# make sure to get a nice path without //
- local instpath=${d#${D}}
+ local instpath=${d#${D%/}}
instpath=/${instpath##/}
case "${EPYTHON}" in
doins -r "${@}" || return ${?}
)
- python_optimize "${ED}/${d}"
+ python_optimize "${ED%/}/${d}"
}
# @FUNCTION: python_doheader
python_is_installed() {
local impl=${1:-${EPYTHON}}
[[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
+ local hasv_args=()
+
+ case ${EAPI:-0} in
+ 0|1|2|3|4)
+ local -x ROOT=/
+ ;;
+ 5|6)
+ hasv_args+=( --host-root )
+ ;;
+ *)
+ hasv_args+=( -b )
+ ;;
+ esac
- # for has_version
- local -x ROOT=/
case "${impl}" in
pypy|pypy3)
local append=
fi
# be happy with just the interpeter, no need for the virtual
- has_version "dev-python/${impl}${append}" \
- || has_version "dev-python/${impl}-bin${append}"
+ has_version "${hasv_args[@]}" "dev-python/${impl}${append}" \
+ || has_version "${hasv_args[@]}" "dev-python/${impl}-bin${append}"
;;
*)
local PYTHON_PKG_DEP
python_export "${impl}" PYTHON_PKG_DEP
- has_version "${PYTHON_PKG_DEP}"
+ has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
;;
esac
}
for i in "${split_shebang[@]}"; do
case "${i}" in
*"${EPYTHON}")
- debug-print "${FUNCNAME}: in file ${f#${D}}"
+ debug-print "${FUNCNAME}: in file ${f#${D%/}}"
debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}"
# Nothing to do, move along.
break
;;
*python|*python[23])
- debug-print "${FUNCNAME}: in file ${f#${D}}"
+ debug-print "${FUNCNAME}: in file ${f#${D%/}}"
debug-print "${FUNCNAME}: rewriting shebang: ${shebang}"
if [[ ${i} == *python2 ]]; then
fi
if [[ ! ${quiet} ]]; then
- einfo "Fixing shebang in ${f#${D}}."
+ einfo "Fixing shebang in ${f#${D%/}}."
fi
if [[ ! ${error} ]]; then
any_fixed=1
else
eerror "The file has incompatible shebang:"
- eerror " file: ${f#${D}}"
+ eerror " file: ${f#${D%/}}"
eerror " current shebang: ${shebang}"
eerror " requested impl: ${EPYTHON}"
die "${FUNCNAME}: conversion of incompatible shebang requested"
local cmd=eerror
[[ ${EAPI:-0} == [012345] ]] && cmd=eqawarn
- "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D}} did not match any fixable files."
+ "${cmd}" "QA warning: ${FUNCNAME}, ${path#${D%/}} did not match any fixable files."
if [[ ${any_correct} ]]; then
"${cmd}" "All files have ${EPYTHON} shebang already."
else