From 7218e1b46bceac05841e90472501742d905fb3fc Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Fri, 12 Mar 2021 21:55:15 +0000 Subject: gentoo resync : 12.03.2021 --- eclass/distutils-r1.eclass | 139 +++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 86 deletions(-) (limited to 'eclass/distutils-r1.eclass') diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index ca2ed98c8e8c..655a33e0d208 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -406,10 +406,10 @@ distutils_enable_sphinx() { distutils_enable_tests() { debug-print-function ${FUNCNAME} "${@}" - local do_install= + _DISTUTILS_TEST_INSTALL= case ${1} in --install) - do_install=1 + _DISTUTILS_TEST_INSTALL=1 shift ;; esac @@ -419,62 +419,21 @@ distutils_enable_tests() { case ${1} in nose) test_pkg=">=dev-python/nose-1.3.7-r4" - if [[ ${do_install} ]]; then - python_test() { - distutils_install_for_testing --via-root - nosetests -v || die "Tests fail with ${EPYTHON}" - } - else - python_test() { - nosetests -v || die "Tests fail with ${EPYTHON}" - } - fi ;; pytest) test_pkg=">=dev-python/pytest-4.5.0" - if [[ ${do_install} ]]; then - python_test() { - distutils_install_for_testing --via-root - pytest -vv || die "Tests fail with ${EPYTHON}" - } - else - python_test() { - pytest -vv || die "Tests fail with ${EPYTHON}" - } - fi ;; setup.py) - if [[ ${do_install} ]]; then - python_test() { - distutils_install_for_testing --via-root - nonfatal esetup.py test --verbose || - die "Tests fail with ${EPYTHON}" - } - else - python_test() { - nonfatal esetup.py test --verbose || - die "Tests fail with ${EPYTHON}" - } - fi ;; unittest) - if [[ ${do_install} ]]; then - python_test() { - distutils_install_for_testing --via-root - "${EPYTHON}" -m unittest discover -v || - die "Tests fail with ${EPYTHON}" - } - else - python_test() { - "${EPYTHON}" -m unittest discover -v || - die "Tests fail with ${EPYTHON}" - } - fi ;; *) die "${FUNCNAME}: unsupported argument: ${1}" esac + _DISTUTILS_TEST_RUNNER=${1} + python_test() { distutils-r1_python_test; } + local test_deps=${RDEPEND} if [[ -n ${test_pkg} ]]; then if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then @@ -714,7 +673,7 @@ distutils-r1_python_configure() { _distutils-r1_create_setup_cfg() { cat > "${HOME}"/.pydistutils.cfg <<-_EOF_ || die [build] - build-base = ${BUILD_DIR} + build_base = ${BUILD_DIR} # using a single directory for them helps us export # ${PYTHONPATH} and ebuilds find the sources independently @@ -723,16 +682,16 @@ _distutils-r1_create_setup_cfg() { # note: due to some packages (wxpython) relying on separate # platlib & purelib dirs, we do not set --build-lib (which # can not be overridden with --build-*lib) - build-platlib = %(build-base)s/lib - build-purelib = %(build-base)s/lib + build_platlib = %(build_base)s/lib + build_purelib = %(build_base)s/lib # make the ebuild writer lives easier - build-scripts = %(build-base)s/scripts + build_scripts = %(build_base)s/scripts # this is needed by distutils_install_for_testing since # setuptools like to create .egg files for install --home. [bdist_egg] - dist-dir = ${BUILD_DIR}/dist + dist_dir = ${BUILD_DIR}/dist _EOF_ # we can't refer to ${D} before src_install() @@ -749,7 +708,7 @@ _distutils-r1_create_setup_cfg() { if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then cat >> "${HOME}"/.pydistutils.cfg <<-_EOF_ || die - install-scripts = $(python_get_scriptdir) + install_scripts = $(python_get_scriptdir) _EOF_ fi fi @@ -841,6 +800,48 @@ _distutils-r1_wrap_scripts() { fi } +# @FUNCTION: distutils-r1_python_test +# @USAGE: [additional-args...] +# @DESCRIPTION: +# The python_test() implementation used by distutils_enable_tests. +# Runs tests using the specified test runner, possibly installing them +# first. +# +# This function is used only if distutils_enable_tests is called. +distutils-r1_python_test() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ -z ${_DISTUTILS_TEST_RUNNER} ]]; then + die "${FUNCNAME} can be only used after calling distutils_enable_tests" + fi + + if [[ ${_DISTUTILS_TEST_INSTALL} ]]; then + distutils_install_for_testing + fi + + case ${_DISTUTILS_TEST_RUNNER} in + nose) + nosetests -v "${@}" + ;; + pytest) + epytest + ;; + setup.py) + nonfatal esetup.py test --verbose + ;; + unittest) + "${EPYTHON}" -m unittest discover -v + ;; + *) + die "Mis-synced test runner between ${FUNCNAME} and distutils_enable_testing" + ;; + esac + + if [[ ${?} -ne 0 ]]; then + die "Tests failed with ${EPYTHON}" + fi +} + # @FUNCTION: distutils-r1_python_install # @USAGE: [additional-args...] # @DESCRIPTION: @@ -1185,39 +1186,5 @@ distutils-r1_src_install() { _distutils-r1_check_namespace_pth } -# -- distutils.eclass functions -- - -distutils_get_intermediate_installation_image() { - die "${FUNCNAME}() is invalid for distutils-r1" -} - -distutils_src_unpack() { - die "${FUNCNAME}() is invalid for distutils-r1, and you don't want it in EAPI ${EAPI} anyway" -} - -distutils_src_prepare() { - die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}" -} - -distutils_src_compile() { - die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}" -} - -distutils_src_test() { - die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}" -} - -distutils_src_install() { - die "${FUNCNAME}() is invalid for distutils-r1, you probably want: ${FUNCNAME/_/-r1_}" -} - -distutils_pkg_postinst() { - die "${FUNCNAME}() is invalid for distutils-r1, and pkg_postinst is unnecessary" -} - -distutils_pkg_postrm() { - die "${FUNCNAME}() is invalid for distutils-r1, and pkg_postrm is unnecessary" -} - _DISTUTILS_R1=1 fi -- cgit v1.2.3