diff setup.py @ 41:71bcc18e306f

MERGE: New upstream PyMuPDF v1.26.5 including MuPDF v1.26.10 BUGS: Needs some additional changes yet. Not yet tested.
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 11 Oct 2025 15:24:40 +0200
parents 14b91574d44a a6bc019ac0b2
children 0a8b06e38e19
line wrap: on
line diff
--- a/setup.py	Tue Sep 23 10:27:15 2025 +0200
+++ b/setup.py	Sat Oct 11 15:24:40 2025 +0200
@@ -88,11 +88,12 @@
             Empty string:
                 Build PyMuPDF with the system MuPDF.
             A string starting with 'git:':
-                Use `git clone` to get a MuPDF checkout. We use the
-                string in the git clone command; it must contain the git
-                URL from which to clone, and can also contain other `git
-                clone` args, for example:
-                    PYMUPDF_SETUP_MUPDF_BUILD="git:--branch master https://github.com/ArtifexSoftware/mupdf.git"
+                We use `git` commands to clone/update a local MuPDF checkout.
+                Should match `git:[--branch <branch>][--tag <tag>][<remote>]`.
+                If <remote> is omitted we use a default.
+                For example:
+                    PYMUPDF_SETUP_MUPDF_BUILD="git:--branch master"
+                Passed as <text> arg to pipcl.git_get().
             Otherwise:
                 Location of mupdf directory.
     
@@ -461,7 +462,7 @@
 
 mupdf_tgz = os.path.abspath( f'{__file__}/../mupdf.tgz')
 
-def get_mupdf_internal(out, location=None, sha=None, local_tgz=None):
+def get_mupdf_internal(out, location=None, local_tgz=None):
     '''
     Gets MuPDF as either a .tgz or a local directory.
     
@@ -474,8 +475,6 @@
             If starts with 'git:', should be remote git location.
             Otherwise if containing '://' should be URL for .tgz.
             Otherwise should path of local mupdf checkout.
-        sha:
-            If not None and we use git clone, we checkout this sha.
         local_tgz:
             If not None, must be local .tgz file.
     Returns:
@@ -487,7 +486,7 @@
             default location.
                 
     '''
-    log(f'get_mupdf_internal(): {out=} {location=} {sha=}')
+    log(f'get_mupdf_internal(): {out=} {location=}')
     assert out in ('dir', 'tgz')
     if location is None:
         location = f'https://mupdf.com/downloads/archive/mupdf-{version_mupdf}-source.tar.gz'
@@ -501,21 +500,15 @@
     if local_tgz:
         assert os.path.isfile(local_tgz)
     elif location.startswith( 'git:'):
-        location_git = location[4:]
         local_dir = 'mupdf-git'
+        pipcl.git_get(local_dir, text=location, remote='https://github.com/ArtifexSoftware/mupdf.git')
         
-        # Try to update existing checkout.
-        e = run(f'cd {local_dir} && git pull && git submodule update --init', check=False)
-        if e:
-            # No existing git checkout, so do a fresh clone.
-            _fs_remove(local_dir)
-            gitargs = location[4:]
-            run(f'git clone --recursive --depth 1 --shallow-submodules {gitargs} {local_dir}')
-
         # Show sha of checkout.
-        run( f'cd {local_dir} && git show --pretty=oneline|head -n 1', check=False)
-        if sha:
-            run( f'cd {local_dir} && git checkout {sha}')
+        run(
+                f'cd {local_dir} && git show --pretty=oneline|head -n 1',
+                check = False,
+                prefix = 'mupdf git id: ',
+                )
     elif '://' in location:
         # Download .tgz.
         local_tgz = os.path.basename( location)
@@ -610,14 +603,10 @@
 windows = platform.system() == 'Windows' or platform.system().startswith('CYGWIN')
 msys2 = platform.system().startswith('MSYS_NT-')
 
-pyodide_flags = '-fwasm-exceptions'
-
 if os.environ.get('PYODIDE') == '1':
     if os.environ.get('OS') != 'pyodide':
         log('PYODIDE=1, setting OS=pyodide.')
         os.environ['OS'] = 'pyodide'
-        os.environ['XCFLAGS'] = pyodide_flags
-        os.environ['XCXXFLAGS'] = pyodide_flags
 
 pyodide = os.environ.get('OS') == 'pyodide'
 
@@ -740,8 +729,8 @@
             add('d', f'{mupdf_build_dir}/libmupdf-threads.a', f'{to_dir_d}/lib/')
         elif pyodide:
             add('p', f'{mupdf_build_dir}/_mupdf.so', to_dir)
-            add('b', f'{mupdf_build_dir}/libmupdfcpp.so', 'PyMuPDF.libs/')
-            add('b', f'{mupdf_build_dir}/libmupdf.so', 'PyMuPDF.libs/')
+            add('b', f'{mupdf_build_dir}/libmupdfcpp.so', to_dir)
+            add('b', f'{mupdf_build_dir}/libmupdf.so', to_dir)
         else:
             add('p', f'{mupdf_build_dir}/_mupdf.so', to_dir)
             add('b', pipcl.get_soname(f'{mupdf_build_dir}/libmupdfcpp.so'), to_dir)
@@ -784,6 +773,7 @@
         except Exception:
             return 0
     swig_version_tuple = tuple(int_or_0(i) for i in swig_version.split('.'))
+    version_p_tuple = tuple(int_or_0(i) for i in version_p.split('.'))
     log(f'{swig_version=}')
     text = ''
     if os.path.isdir(mupdf_location):
@@ -792,6 +782,7 @@
     else:
         text += f'mupdf_location = {mupdf_location!r}\n'
     text += f'pymupdf_version = {version_p!r}\n'
+    text += f'pymupdf_version_tuple = {version_p_tuple!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'
@@ -1258,9 +1249,6 @@
         if cxxflags:
             compiler_extra += f' {cxxflags}'
 
-    if pyodide:
-        compiler_extra += f' {pyodide_flags}'
-        linker_extra += f' {pyodide_flags}'
 
     if not darwin and (platform.system() != 'Windows'):
         # *BSD and Linux
@@ -1335,9 +1323,9 @@
 #
 
 # PyMuPDF version.
-version_p = '1.26.4+2'
+version_p = '1.26.5+XXXFIXME0'
 
-version_mupdf = '1.26.7'
+version_mupdf = '1.26.10'
 
 # PyMuPDFb version. This is the PyMuPDF version whose PyMuPDFb wheels we will
 # (re)use if generating separate PyMuPDFb wheels. Though as of PyMuPDF-1.24.11
@@ -1474,9 +1462,6 @@
             ret.append(libclang)
         elif openbsd:
             print(f'OpenBSD: libclang not available via pip; assuming `pkg_add py3-llvm`.')
-        elif darwin and platform.machine() == 'arm64':
-            print(f'MacOS/arm64: forcing use of libclang 16.0.6 because 18.1.1 known to fail with `clang.cindex.TranslationUnitLoadError: Error parsing translation unit.`')
-            ret.append('libclang==16.0.6')
         elif darwin and platform_release_tuple() < (18,):
             # There are still of problems when building on old macos.
             ret.append('libclang==14.0.6')