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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EAB4E138334 for ; Wed, 20 Nov 2019 18:23:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 79949E0870; Wed, 20 Nov 2019 18:23:36 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1622CE0809 for ; Wed, 20 Nov 2019 18:23:36 +0000 (UTC) Received: from patrickm.gaikai.org (unknown [100.42.98.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: chutzpah) by smtp.gentoo.org (Postfix) with ESMTPSA id CF78B34D14C; Wed, 20 Nov 2019 18:23:34 +0000 (UTC) Date: Wed, 20 Nov 2019 10:23:27 -0800 From: Patrick McLean To: =?UTF-8?B?TWljaGHFgiBHw7Nybnk=?= Cc: gentoo-dev@lists.gentoo.org, python@gentoo.org Subject: Re: [gentoo-dev] [PATCH 1/4] distutils-r1.eclass: Add distutils_enable_sphinx helper function Message-ID: <20191120102327.0edcafcd@patrickm.gaikai.org> In-Reply-To: <20191120142158.157436-1-mgorny@gentoo.org> References: <20191120142158.157436-1-mgorny@gentoo.org> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: a7526d63-6173-49d2-9f49-f24ca28100dc X-Archives-Hash: c9d850592b43a686dd4fd1025b742d1b Hi Micha=C5=82, Thanks for doing this work, it's always better to have standardized ways of doing things. On Wed, 20 Nov 2019 15:21:55 +0100 Micha=C5=82 G=C3=B3rny wrote: > +distutils_enable_sphinx() { > + debug-print-function ${FUNCNAME} "${@}" > + [[ ${#} -ge 1 ]] || die "${FUNCNAME} takes at least one arg: " > + > + _DISTUTILS_SPHINX_SUBDIR=3D${1} > + shift > + _DISTUTILS_SPHINX_PLUGINS=3D( "${@}" ) > + > + local deps autodoc=3D1 d > + for d; do > + if [[ ${d} =3D=3D --no-autodoc ]]; then > + autodoc=3D > + else > + deps+=3D" > + ${d}[\${PYTHON_USEDEP}]" > + fi > + done > + > + if [[ ! ${autodoc} && -n ${deps} ]]; then > + die "${FUNCNAME}: do not pass --no-autodoc if external plugins are use= d" > + fi > + if [[ ${autodoc} ]]; then > + deps=3D"$(python_gen_any_dep " > + dev-python/sphinx[\${PYTHON_USEDEP}] > + ${deps}")" > + > + python_check_deps() { > + use doc || return 0 > + local p > + for p in "${_DISTUTILS_SPHINX_PLUGINS[@]}"; do > + has_version "${p}[${PYTHON_USEDEP}]" || return 1 > + done > + } I think it would be better to put this code in sphinx_check_deps (or some such) and define a python_check_deps that just calls sphinx_check_deps. That would allow ebuilds that need to do more than the sphinx stuff to not have to reimplement this. > + else > + deps=3D"dev-python/sphinx" > + fi > + > + python_compile_all() { > + use doc || return > + > + cd "${_DISTUTILS_SPHINX_SUBDIR}" || die > + [[ -f conf.py ]] || > + die "conf.py not found, distutils_enable_sphinx call wrong" > + > + if [[ ${_DISTUTILS_SPHINX_PLUGINS[0]} =3D=3D --no-autodoc ]]; then > + if grep -q 'sphinx\.ext\.autodoc' "conf.py"; then Since this is just searching for a fixed string maybe "grep -F -q 'sphinx.ext.autodoc'" is a bit nicer. > + die "distutils_enable_sphinx: --no-autodoc passed but sphinx.ext.aut= odoc found in conf.py" > + fi > + else > + if ! grep -q 'sphinx\.ext\.autodoc' "conf.py"; then > + die "distutils_enable_sphinx: sphinx.ext.autodoc not found in conf.p= y, pass --no-autodoc" > + fi > + fi > + > + # disable intersphinx (internet use) > + sed -e 's:^intersphinx_mapping:disabled_&:' -i conf.py || die > + # not all packages include the Makefile in pypi tarball > + sphinx-build -b html -d _build/doctrees . _build/html || die > + > + HTML_DOCS+=3D( "${_DISTUTILS_SPHINX_SUBDIR}/_build/html/." ) > + } Same as above, I think it would be better to define this as sphinx_compile, and define a python_compile_all that just calls it. That way if an ebuild defines it's own python_compile_all it can call sphinx_compile to get this functionality. > + > + IUSE+=3D" doc" > + if [[ ${EAPI} =3D=3D [56] ]]; then > + DEPEND+=3D" doc? ( ${deps} )" > + else > + BDEPEND+=3D" doc? ( ${deps} )" > + fi > + > + # we need to ensure successful return in case we're called last, > + # otherwise Portage may wrongly assume sourcing failed > + return 0 > +} > + > # @FUNCTION: distutils_enable_tests > # @USAGE: > # @DESCRIPTION: