commit:     5dd0b3434fabac6e209a454a26ba2a0cc386a850
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 15 15:38:30 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Oct 15 16:04:26 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5dd0b343

dev-util/pkgdev: fix docs generation

Closes: https://bugs.gentoo.org/877189
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 dev-util/pkgdev/files/pkgdev-0.2.3-docs-path.patch | 47 ++++++++++++++++++++++
 dev-util/pkgdev/pkgdev-0.2.3.ebuild                | 12 ++++--
 dev-util/pkgdev/pkgdev-9999.ebuild                 |  8 ++--
 3 files changed, 59 insertions(+), 8 deletions(-)

diff --git a/dev-util/pkgdev/files/pkgdev-0.2.3-docs-path.patch 
b/dev-util/pkgdev/files/pkgdev-0.2.3-docs-path.patch
new file mode 100644
index 000000000000..3386c3e96cff
--- /dev/null
+++ b/dev-util/pkgdev/files/pkgdev-0.2.3-docs-path.patch
@@ -0,0 +1,47 @@
+https://github.com/pkgcore/pkgdev/commit/640c78d7
+
+doc: fix generating of code when built in PEP517 mode
+
+When in PEP517 mode, the source code is located in a different location,
+so use better relative fallback place. Also cleanup a little the code
+handling to use pathlib.
+
+Bug: https://bugs.gentoo.org/877189
+Signed-off-by: Arthur Zamarin <arthur...@gentoo.org>
+--- a/doc/conf.py
++++ b/doc/conf.py
+@@ -16,13 +16,17 @@
+ import os
+ import sys
+ from importlib import import_module
++from pathlib import Path
+
+ # If extensions (or modules to document with autodoc) are in another 
directory,
+ # add these directories to sys.path here. If the directory is relative to the
+ # documentation root, use os.path.abspath to make it absolute, like shown 
here.
+-libdir = os.path.abspath(os.path.join('..', 'build', 'lib'))
+-if os.path.exists(libdir):
+-    sys.path.insert(0, libdir)
++
++if (src_path := Path(__file__).parent.parent / 'src').is_dir():
++    sys.path.insert(0, str(src_path.resolve()))
++
++if (libdir := Path(__file__).parent.parent / 'build/lib').is_dir():
++    sys.path.insert(0, str(libdir.resolve()))
+
+ os.environ['PKGDIST_REPODIR'] = os.path.abspath('..')
+ from snakeoil.dist import distutils_extensions as pkgdist
+@@ -241,11 +245,9 @@
+
+ # -- Options for manual page output ---------------------------------------
+
+-bin_path = 
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'bin')
+-scripts = os.listdir(bin_path)
+-
+ generated_man_pages = [
+-    (f"{project}.scripts.{s.replace('-', '_')}", s) for s in scripts
++    (f"{project}.scripts.{s.name.replace('-', '_')}", s.name)
++    for s in (Path(__file__).parent.parent / 'bin').iterdir()
+ ]
+
+ # One entry per manual page. List of tuples

diff --git a/dev-util/pkgdev/pkgdev-0.2.3.ebuild 
b/dev-util/pkgdev/pkgdev-0.2.3.ebuild
index 0599a544b7a9..242f46ae1906 100644
--- a/dev-util/pkgdev/pkgdev-0.2.3.ebuild
+++ b/dev-util/pkgdev/pkgdev-0.2.3.ebuild
@@ -8,8 +8,6 @@ PYTHON_COMPAT=( python3_{8..11} )
 inherit distutils-r1
 
 if [[ ${PV} == *9999 ]] ; then
-       PKGDEV_DOCS_PREBUILT=0
-
        EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/pkgcore/pkgdev.git
                https://github.com/pkgcore/pkgdev.git";
        inherit git-r3
@@ -48,8 +46,14 @@ RDEPEND+="dev-vcs/git"
 distutils_enable_sphinx doc
 distutils_enable_tests setup.py
 
+PATCHES=(
+       "${FILESDIR}/pkgdev-0.2.3-docs-path.patch"
+)
+
 python_compile_all() {
-       use doc && emake -C doc man
+       if use doc; then
+               "${EPYTHON}" setup.py build_man -f || die
+       fi
 
        # HTML pages only
        sphinx_compile_all
@@ -58,7 +62,7 @@ python_compile_all() {
 python_install_all() {
        # If USE=doc, there'll be newly generated docs which we install instead.
        if use doc; then
-               doman doc/_build/man/*
+               doman build/sphinx/man/*
        elif [[ ${PV} != *9999 ]]; then
                doman man/*.[0-8]
        fi

diff --git a/dev-util/pkgdev/pkgdev-9999.ebuild 
b/dev-util/pkgdev/pkgdev-9999.ebuild
index 0599a544b7a9..f42159a4c268 100644
--- a/dev-util/pkgdev/pkgdev-9999.ebuild
+++ b/dev-util/pkgdev/pkgdev-9999.ebuild
@@ -8,8 +8,6 @@ PYTHON_COMPAT=( python3_{8..11} )
 inherit distutils-r1
 
 if [[ ${PV} == *9999 ]] ; then
-       PKGDEV_DOCS_PREBUILT=0
-
        EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/pkgcore/pkgdev.git
                https://github.com/pkgcore/pkgdev.git";
        inherit git-r3
@@ -49,7 +47,9 @@ distutils_enable_sphinx doc
 distutils_enable_tests setup.py
 
 python_compile_all() {
-       use doc && emake -C doc man
+       if use doc; then
+               "${EPYTHON}" setup.py build_man -f || die
+       fi
 
        # HTML pages only
        sphinx_compile_all
@@ -58,7 +58,7 @@ python_compile_all() {
 python_install_all() {
        # If USE=doc, there'll be newly generated docs which we install instead.
        if use doc; then
-               doman doc/_build/man/*
+               doman build/sphinx/man/*
        elif [[ ${PV} != *9999 ]]; then
                doman man/*.[0-8]
        fi

Reply via email to