diff --git a/changes.txt b/changes.txt index f56227808..242ad1dbe 100644 --- a/changes.txt +++ b/changes.txt @@ -26,7 +26,7 @@ Change Log * Retrospectively mark `4544 `_ as fixed in 1.26.4. -**Changes in version 1.26.4** +**Changes in version 1.26.4 (2025-08-25)** * Use MuPDF-1.26.7. diff --git a/scripts/test.py b/scripts/test.py index 5b0cca79c..3ab1396c4 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -95,6 +95,10 @@ --cibw-release-2 Set up so that `cibw` builds only linux-aarch64 wheel. + --cibw-skip-add-defaults 0|1 + If 1 (the default) we add defaults to CIBW_SKIP such as `pp*` (to + exclude pypy) and `cp3??t-*` (to exclude free-threading). + --cibw-test-project 0|1 If 1, command `cibw` will use a minimal test project instead of the PyMuPDF directory itself. @@ -406,6 +410,7 @@ def main(argv): cibw_name = None cibw_pyodide = None cibw_pyodide_version = None + cibw_skip_add_defaults = True cibw_test_project = None commands = list() env_extra = dict() @@ -474,7 +479,7 @@ def main(argv): env_extra['CIBW_ARCHS_LINUX'] = 'auto64' env_extra['CIBW_ARCHS_MACOS'] = 'auto64' env_extra['CIBW_ARCHS_WINDOWS'] = 'auto' # win32 and win64. - env_extra['CIBW_SKIP'] = 'pp* *i686 cp36* cp37* *musllinux*aarch64*' + env_extra['CIBW_SKIP'] = '*musllinux*aarch64*' elif arg == '--cibw-release-2': env_extra['CIBW_ARCHS_LINUX'] = 'aarch64' @@ -493,6 +498,9 @@ def main(argv): elif arg == '--cibw-pyodide': cibw_pyodide = int(next(args)) + elif arg == '--cibw-skip-add-defaults': + cibw_skip_add_defaults = int(next(args)) + elif arg == '--cibw-test-project': cibw_test_project = int(next(args)) @@ -707,6 +715,7 @@ def main(argv): cibw_pyodide_version, cibw_sdist, cibw_test_project, + cibw_skip_add_defaults, ) elif command == 'install': @@ -857,6 +866,7 @@ def cibuildwheel( cibw_pyodide_version, cibw_sdist, cibw_test_project, + cibw_skip_add_defaults, ): if cibw_sdist and platform.system() == 'Linux': @@ -871,9 +881,19 @@ def cibuildwheel( # Some general flags. if 'CIBW_BUILD_VERBOSITY' not in env_extra: env_extra['CIBW_BUILD_VERBOSITY'] = '1' - if 'CIBW_SKIP' not in env_extra: - env_extra['CIBW_SKIP'] = 'pp* *i686 cp36* cp37* *musllinux* *-win32 *-aarch64' - + + # Add default flags to CIBW_SKIP. + # 2025-10-07: `cp3??t-*` excludes free-threading, which currently breaks + # some tests. + + if cibw_skip_add_defaults: + CIBW_SKIP = env_extra.get('CIBW_SKIP', '') + CIBW_SKIP += ' pp* *i686 cp36* cp37* *musllinux* *-win32 *-aarch64 cp3??t-*' + CIBW_SKIP = CIBW_SKIP.split() + CIBW_SKIP = sorted(list(set(CIBW_SKIP))) + CIBW_SKIP = ' '.join(CIBW_SKIP) + env_extra['CIBW_SKIP'] = CIBW_SKIP + # Set what wheels to build, if not already specified. if 'CIBW_ARCHS' not in env_extra: if 'CIBW_ARCHS_WINDOWS' not in env_extra: @@ -929,10 +949,14 @@ def cibuildwheel( env_extra['CIBW_PYODIDE_VERSION'] = cibw_pyodide_version env_extra['CIBW_ENABLE'] = 'pyodide-prerelease' - # Pass all the environment variables we have set, to Linux - # docker. Note that this will miss any settings in the original - # environment. - env_extra['CIBW_ENVIRONMENT_PASS_LINUX'] = ' '.join(sorted(env_extra.keys())) + # Pass all the environment variables we have set, to Linux docker. Note + # that this will miss any settings in the original environment. We have to + # add CIBW_BUILD explicitly because we haven't set it yet. + CIBW_ENVIRONMENT_PASS_LINUX = set(env_extra.keys()) + CIBW_ENVIRONMENT_PASS_LINUX.add('CIBW_BUILD') + CIBW_ENVIRONMENT_PASS_LINUX = sorted(list(CIBW_ENVIRONMENT_PASS_LINUX)) + CIBW_ENVIRONMENT_PASS_LINUX = ' '.join(CIBW_ENVIRONMENT_PASS_LINUX) + env_extra['CIBW_ENVIRONMENT_PASS_LINUX'] = CIBW_ENVIRONMENT_PASS_LINUX if cibw_test_project: cibw_do_test_project(env_extra, CIBW_BUILD, cibw_pyodide, cibw_pyodide_args) diff --git a/tests/resources/test_4699.pdf b/tests/resources/test_4699.pdf new file mode 100644 index 000000000..79ad74ced Binary files /dev/null and b/tests/resources/test_4699.pdf differ diff --git a/tests/resources/test_4699.png b/tests/resources/test_4699.png new file mode 100644 index 000000000..e67380d3a Binary files /dev/null and b/tests/resources/test_4699.png differ diff --git a/tests/test_pixmap.py b/tests/test_pixmap.py index 97f0ff0ed..39fc2b5da 100644 --- a/tests/test_pixmap.py +++ b/tests/test_pixmap.py @@ -631,3 +631,22 @@ def test_4388(): assert rms == 0 else: assert rms >= 10 + + +def test_4699(): + path = os.path.normpath(f'{__file__}/../../tests/resources/test_4699.pdf') + path_png_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_4699.png') + path_png_actual = os.path.normpath(f'{__file__}/../../tests/test_4699.png') + with pymupdf.open(path) as document: + page = document[0] + pixmap = page.get_pixmap() + pixmap.save(path_png_actual) + print(f'Have saved to {path_png_actual=}.') + rms = gentle_compare.pixmaps_rms(path_png_expected, pixmap) + print(f'test_4699(): {rms=}') + if pymupdf.mupdf_version_tuple >= (1, 27): + assert rms == 0 + else: + wt = pymupdf.TOOLS.mupdf_warnings() + assert 'syntax error: cannot find ExtGState resource' in wt + assert rms > 20 diff --git a/tests/test_release.py b/tests/test_release.py index 7c3e56ae8..ac3782973 100644 --- a/tests/test_release.py +++ b/tests/test_release.py @@ -5,15 +5,17 @@ import sys -g_root = os.path.normpath(f'{__file__}/../../') -g_root = os.path.relpath(g_root) +g_root_abs = os.path.normpath(f'{__file__}/../../') -sys.path.insert(0, g_root) +sys.path.insert(0, g_root_abs) try: + import pipcl import setup finally: del sys.path[0] +g_root = pipcl.relpath(g_root_abs) + def _file_line(path, text, re_match, offset=+2): '''