Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,17 @@ def add(flavour, from_, to_):
add('d', f'{header_abs}', f'{to_dir_d}/include/{header_rel}')

# Add a .py file containing location of MuPDF.
text = f"mupdf_location='{mupdf_location}'\n"
try:
sha, comment, diff, branch = git_info(g_root)
except Exception as e:
log(f'Failed to get git information: {e}')
sha, comment, diff, branch = (None, None, None, None)
text = ''
text += f'mupdf_location = {mupdf_location!r}\n'
text += f'pymupdf_version = {version_p!r}\n'
text += f'pymupdf_git_sha = {sha!r}\n'
text += f'pymupdf_git_diff = {diff!r}\n'
text += f'pymupdf_git_branch = {branch!r}\n'
add('p', text.encode(), f'{to_dir}/_build.py')

# Add single README file.
Expand Down
12 changes: 11 additions & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,18 @@ def _int_rc(text):

# Basic version information.
#
pymupdf_version = "1.26.3"
# (We use `noqa F401` to avoid flake8 errors such as `F401
# '._build.mupdf_location' imported but unused`.
#
from ._build import mupdf_location # noqa F401
from ._build import pymupdf_git_branch # noqa F401
from ._build import pymupdf_git_diff # noqa F401
from ._build import pymupdf_git_sha # noqa F401
from ._build import pymupdf_version # noqa F401

mupdf_version = mupdf.FZ_VERSION

# Removed in PyMuPDF-1.26.1.
pymupdf_date = None

# Versions as tuples; useful when comparing versions.
Expand Down
14 changes: 14 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -1946,3 +1946,17 @@ def test_4496():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4496.hwpx')
with pymupdf.open(path) as document:
print(document.page_count)


def test_gitinfo():
# This doesn't really test very much, but can be useful to see the current
# values.
print('')
print(f'test_4496():')
print(f'{pymupdf.mupdf_location=}')
print(f'{pymupdf.mupdf_version=}')
print(f'{pymupdf.pymupdf_git_branch=}')
print(f'{pymupdf.pymupdf_git_sha=}')
print(f'{pymupdf.pymupdf_version=}')
print(f'pymupdf.pymupdf_git_diff:\n{textwrap.indent(pymupdf.pymupdf_git_diff, " ")}')