From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 947D015800A for ; Fri, 14 Jul 2023 07:48:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 14968E084F; Fri, 14 Jul 2023 07:48:27 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C6D33E0817 for ; Fri, 14 Jul 2023 07:48:26 +0000 (UTC) Message-ID: <73de1f68-8f1c-19bb-b0f9-100b89812be7@gentoo.org> Date: Fri, 14 Jul 2023 09:48:22 +0200 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US, nl-NL To: gentoo-dev@lists.gentoo.org From: Andrew Ammerlaan Organization: Gentoo Linux Subject: [gentoo-dev] [PATCH 1/1] docs.eclass: add missing python_check_deps() deceleration Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Archives-Salt: d0e39534-70d3-45c9-bf58-38358254fba5 X-Archives-Hash: f4806063756082e1f24713c44d82652f This patch moves some things around so we can then easily define a python_check_deps() function. The lack of this function causes problems when building the documentation of packages that already have py3.12 in compat while mkdocs does not have py3.12 yet. [1] As an added bonus, some code duplication is removed. Best regards, Andrew [1] https://bugs.gentoo.org/910278 From 4f758c021094db0e4f2a085aba33a614f97200d1 Mon Sep 17 00:00:00 2001 From: Andrew Ammerlaan Date: Fri, 14 Jul 2023 09:40:59 +0200 Subject: [PATCH] docs.eclass: define python_check_deps() and remove some code duplication Closes: https://bugs.gentoo.org/910278 Signed-off-by: Andrew Ammerlaan --- eclass/docs.eclass | 59 ++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/eclass/docs.eclass b/eclass/docs.eclass index da598226bfc0..1aa4937a6363 100644 --- a/eclass/docs.eclass +++ b/eclass/docs.eclass @@ -186,21 +186,36 @@ initialize_git_repo() { fi } -# @FUNCTION: python_append_deps +# @FUNCTION: _docs_set_python_deps # @INTERNAL # @DESCRIPTION: -# Appends [\${PYTHON_USEDEP}] to all dependencies -# for python based DOCS_BUILDERs such as mkdocs or -# sphinx. -python_append_deps() { +# Add python_gen_any_dep or python_gen_cond_dep +# to DOCS_DEPEND and define python_check_deps +_docs_set_python_deps() { debug-print-function ${FUNCNAME} - local temp + local deps=${@} + python_check_deps() { + use doc || return 0 + + local dep + for dep in ${deps[@]}; do + python_has_version "${dep}[${PYTHON_USEDEP}]" || + return 1 + done + } + + local deps_appended local dep - for dep in ${DOCS_DEPEND[@]}; do - temp+=" ${dep}[\${PYTHON_USEDEP}]" + for dep in ${deps[@]}; do + deps_appended+=" ${dep}[\${PYTHON_USEDEP}]" done - DOCS_DEPEND=${temp} + + if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then + DOCS_DEPEND=$(python_gen_cond_dep "${deps_appended}") + else + DOCS_DEPEND=$(python_gen_any_dep "${deps_appended}") + fi } # @FUNCTION: sphinx_deps @@ -212,8 +227,8 @@ sphinx_deps() { : "${DOCS_AUTODOC:=1}" - deps="dev-python/sphinx[\${PYTHON_USEDEP}] - ${DOCS_DEPEND}" + deps="dev-python/sphinx + ${DOCS_DEPEND}" if [[ ${DOCS_AUTODOC} == 0 ]]; then if [[ -n "${DOCS_DEPEND}" ]]; then die "${FUNCNAME}: do not set DOCS_AUTODOC to 0 if external plugins are used" @@ -221,11 +236,8 @@ sphinx_deps() { elif [[ ${DOCS_AUTODOC} != 0 && ${DOCS_AUTODOC} != 1 ]]; then die "${FUNCNAME}: DOCS_AUTODOC should be set to 0 or 1" fi - if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then - DOCS_DEPEND="$(python_gen_cond_dep "${deps}")" - else - DOCS_DEPEND="$(python_gen_any_dep "${deps}")" - fi + + _docs_set_python_deps ${deps} } # @FUNCTION: sphinx_compile @@ -276,19 +288,16 @@ mkdocs_deps() { : "${DOCS_AUTODOC:=0}" - deps="dev-python/mkdocs[\${PYTHON_USEDEP}] - ${DOCS_DEPEND}" + deps="dev-python/mkdocs + ${DOCS_DEPEND}" if [[ ${DOCS_AUTODOC} == 1 ]]; then - deps="dev-python/mkautodoc[\${PYTHON_USEDEP}] + deps="dev-python/mkautodoc ${deps}" elif [[ ${DOCS_AUTODOC} != 0 && ${DOCS_AUTODOC} != 1 ]]; then die "${FUNCNAME}: DOCS_AUTODOC should be set to 0 or 1" fi - if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then - DOCS_DEPEND="$(python_gen_cond_dep "${deps}")" - else - DOCS_DEPEND="$(python_gen_any_dep "${deps}")" - fi + + _docs_set_python_deps ${deps} } # @FUNCTION: mkdocs_compile @@ -404,11 +413,9 @@ IUSE+=" doc" # Call the correct setup function case ${DOCS_BUILDER} in "sphinx") - python_append_deps sphinx_deps ;; "mkdocs") - python_append_deps mkdocs_deps ;; "doxygen") -- 2.41.0