Skip to content

Commit 640c78d

Browse files
committed
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 <arthurzam@gentoo.org>
1 parent a1d59d9 commit 640c78d

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

doc/conf.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616
import os
1717
import sys
1818
from importlib import import_module
19+
from pathlib import Path
1920

2021
# If extensions (or modules to document with autodoc) are in another directory,
2122
# add these directories to sys.path here. If the directory is relative to the
2223
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
libdir = os.path.abspath(os.path.join('..', 'build', 'lib'))
24-
if os.path.exists(libdir):
25-
sys.path.insert(0, libdir)
24+
25+
if (src_path := Path(__file__).parent.parent / 'src').is_dir():
26+
sys.path.insert(0, str(src_path.resolve()))
27+
28+
if (libdir := Path(__file__).parent.parent / 'build/lib').is_dir():
29+
sys.path.insert(0, str(libdir.resolve()))
2630

2731
os.environ['PKGDIST_REPODIR'] = os.path.abspath('..')
2832
from snakeoil.dist import distutils_extensions as pkgdist
@@ -241,11 +245,9 @@
241245

242246
# -- Options for manual page output ---------------------------------------
243247

244-
bin_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'bin')
245-
scripts = os.listdir(bin_path)
246-
247248
generated_man_pages = [
248-
(f"{project}.scripts.{s.replace('-', '_')}", s) for s in scripts
249+
(f"{project}.scripts.{s.name.replace('-', '_')}", s.name)
250+
for s in (Path(__file__).parent.parent / 'bin').iterdir()
249251
]
250252

251253
# One entry per manual page. List of tuples

0 commit comments

Comments
 (0)