Mercurial > hgrepos > Python2 > PyMuPDF
changeset 23:3b13504f9d89
Use the official packaging.version.Version to parse version strings.
While there revert the previons change to _int_rc(): it is not needed
now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 19 Sep 2025 12:40:07 +0200 |
| parents | d77477b4e151 |
| children | 21c6080bc183 |
| files | setup.py src/__init__.py |
| diffstat | 2 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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,
--- 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)=}'
