Skip to content

Commit 79699b4

Browse files
setup.py: add swig verison to _build.py.
1 parent 74f2e7b commit 79699b4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

setup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,12 +736,27 @@ def add(flavour, from_, to_):
736736
except Exception as e:
737737
log(f'Failed to get git information: {e}')
738738
sha, comment, diff, branch = (None, None, None, None)
739+
swig = PYMUPDF_SETUP_SWIG or 'swig'
740+
swig_version_text = run(f'{swig} --version', capture=1)
741+
m = re.search('\nSWIG Version ([^\n]+)', swig_version_text)
742+
log(f'{swig_version_text=}')
743+
assert m, f'Unrecognised {swig_version_text=}'
744+
swig_version = m.group(1)
745+
def int_or_0(text):
746+
try:
747+
return int(text)
748+
except Exception:
749+
return 0
750+
swig_version_tuple = tuple(int_or_0(i) for i in swig_version.split('.'))
751+
log(f'{swig_version=}')
739752
text = ''
740753
text += f'mupdf_location = {mupdf_location!r}\n'
741754
text += f'pymupdf_version = {version_p!r}\n'
742755
text += f'pymupdf_git_sha = {sha!r}\n'
743756
text += f'pymupdf_git_diff = {diff!r}\n'
744757
text += f'pymupdf_git_branch = {branch!r}\n'
758+
text += f'swig_version = {swig_version!r}\n'
759+
text += f'swig_version_tuple = {swig_version_tuple!r}\n'
745760
add('p', text.encode(), f'{to_dir}/_build.py')
746761

747762
# Add single README file.

0 commit comments

Comments
 (0)