# HG changeset patch # User Franz Glasner # Date 1758278407 -7200 # Node ID 3b13504f9d8945af398b1e86e6b90cb51a30fdac # Parent d77477b4e151fdc58faeedb857936c7b7007b898 Use the official packaging.version.Version to parse version strings. While there revert the previons change to _int_rc(): it is not needed now. diff -r d77477b4e151 -r 3b13504f9d89 setup.py --- a/setup.py Fri Sep 19 12:05:57 2025 +0200 +++ b/setup.py Fri Sep 19 12:40:07 2025 +0200 @@ -1367,6 +1367,12 @@ # We can't pip install pytest on pyodide, so specify it here. requires_dist.append('pytest') + # + # We need packaging because of extended version parsing (including local + # version specifiers. + # + requires_dist.append('packaging') + p = pipcl.Package( name, version, diff -r d77477b4e151 -r 3b13504f9d89 src/__init__.py --- a/src/__init__.py Fri Sep 19 12:05:57 2025 +0200 +++ b/src/__init__.py Fri Sep 19 12:40:07 2025 +0200 @@ -17,6 +17,7 @@ import os import pathlib import glob +import packaging.version import re import string import sys @@ -366,12 +367,8 @@ def _int_rc(text): ''' - Converts string to int, ignoring trailing 'rc...' and a trailing - local version. - ''' - rc = text.find('+') - if rc >= 0: - text = text[:rc] + Converts string to int, ignoring trailing 'rc...'. + ''' rc = text.find('rc') if rc >= 0: text = text[:rc] @@ -397,8 +394,8 @@ # Versions as tuples; useful when comparing versions. # -pymupdf_version_tuple = tuple( [_int_rc(i) for i in pymupdf_version.split('.')]) -mupdf_version_tuple = tuple( [_int_rc(i) for i in mupdf_version.split('.')]) +pymupdf_version_tuple = packaging.version.Version(pymupdf_version).release +mupdf_version_tuple = packaging.version.Version(mupdf_version).release assert mupdf_version_tuple == (mupdf.FZ_VERSION_MAJOR, mupdf.FZ_VERSION_MINOR, mupdf.FZ_VERSION_PATCH), \ f'Inconsistent MuPDF version numbers: {mupdf_version_tuple=} != {(mupdf.FZ_VERSION_MAJOR, mupdf.FZ_VERSION_MINOR, mupdf.FZ_VERSION_PATCH)=}'