Skip to content

Commit 334c37d

Browse files
committed
docs: fix conf after _build.py changes
`docs/conf.py` tries to read version info from `src/__init__py` using an expression match. This breaks after e439a0f ("setup.py src/ tests/: auto-generate pymupdf.pymupdf_version and add git info.", 2025-08-08) makes `src/__init__py` import that info from `_build.py`, which is generated during build in the build directory. Make the build process generate a copy of `_build.py` in `docs` and let `docs/conf.py` import version info from there. Alternative fixes: - pointing `docs/conf.py` at the build directory; this may no longer exist after a wheel build, though - reading from the generated wheel; oh well ;-) - installing the build and importing `_build.py` from there; this would mean intermingling build and install steps
1 parent 69c4ef8 commit 334c37d

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*.swp
55
build/
66
demo/README.rst
7-
docs/build
7+
docs/build
8+
docs/_build.py

docs/conf.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,8 @@
4949
# built documents.
5050
#
5151
# The full version, including alpha/beta/rc tags.
52-
_path = os.path.abspath(f'{__file__}/../../src/__init__.py')
53-
with open(_path) as f:
54-
for line in f:
55-
match = re.search('pymupdf_version = "([0-9][.][0-9]+[.][0-9]+(rc[0-9]+)?)"', line)
56-
if match:
57-
release = match.group(1)
58-
print(f'{__file__}: setting version from {_path}: {release}')
59-
break
60-
else:
61-
raise Exception(f'Failed to find `VersionBind = ...` in {_path}')
52+
from _build import pymupdf_version as release # noqa F401
53+
print(f'{__file__}: setting version from _build.py: {release}')
6254

6355
# The short X.Y version
6456
version = release

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ def add(flavour, from_, to_):
743743
text += f'pymupdf_git_diff = {diff!r}\n'
744744
text += f'pymupdf_git_branch = {branch!r}\n'
745745
add('p', text.encode(), f'{to_dir}/_build.py')
746+
with open('docs/_build.py', 'w') as f:
747+
f.write(text)
746748

747749
# Add single README file.
748750
if 'p' in PYMUPDF_SETUP_FLAVOUR:

0 commit comments

Comments
 (0)