diff --git a/setup.py b/setup.py index 7e9cb34a3..93a555df0 100755 --- a/setup.py +++ b/setup.py @@ -1426,6 +1426,21 @@ def get_requires_for_build_wheel(config_settings=None): #wheel_compression = zipfile.ZIP_DEFLATED if (darwin or pyodide) else zipfile.ZIP_LZMA, wheel_compresslevel = 9, ) + + # Patch up macos platform tag - we require at least 10.15 because otherwise + # std::filesystem appears to be not available. + if pipcl.darwin(): + pt = p.tag_platform() + #pipcl.log(f'{pt=}') + m = re.match('^(macosx_)(([0-9]+)_([0-9]+))(.*)', pt) + #pipcl.log(f'{m=}') + if m: + v = int(m.group(3)), int(m.group(4)) + #pipcl.log(f'{v=}') + if v < (10, 15): + pt2 = f'{m.group(1)}10_15{m.group(5)}' + pipcl.log(f'Changing tag_platform from {pt!r} to {pt2!r}') + p.tag_platform_ = pt2 def get_requires_for_build_wheel(config_settings=None): ''' diff --git a/tests/resources/test_5001.pdf b/tests/resources/test_5001.pdf new file mode 100644 index 000000000..7e17298e2 Binary files /dev/null and b/tests/resources/test_5001.pdf differ diff --git a/tests/resources/test_5001_expected.png b/tests/resources/test_5001_expected.png new file mode 100644 index 000000000..c7c240f37 Binary files /dev/null and b/tests/resources/test_5001_expected.png differ diff --git a/tests/resources/test_natural.pdf b/tests/resources/test_natural.pdf new file mode 100644 index 000000000..e3a26a24d Binary files /dev/null and b/tests/resources/test_natural.pdf differ diff --git a/tests/test_annots.py b/tests/test_annots.py index 6eea26816..4e5b5241e 100644 --- a/tests/test_annots.py +++ b/tests/test_annots.py @@ -727,6 +727,8 @@ def test_4944(): print() with pymupdf.open(path) as document: page = document[0] + print() + print(f'{page.rect=}') print(f'{page.rotation=}') print(f'{page.rotation_matrix=}') print(f'{page.transformation_matrix=}') diff --git a/tests/test_pixmap.py b/tests/test_pixmap.py index ac784dd63..201fa8926 100644 --- a/tests/test_pixmap.py +++ b/tests/test_pixmap.py @@ -667,3 +667,50 @@ def test_4699(): wt = pymupdf.TOOLS.mupdf_warnings() assert 'syntax error: cannot find ExtGState resource' in wt assert rms > 20 + + +def test_5001(): + ''' + #5001 is fixed with mupdf>=1.28. + ''' + path = os.path.normpath(f'{__file__}/../../tests/resources/test_5001.pdf') + path_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_5001_expected.png') + path_out = os.path.normpath(f'{__file__}/../../tests/test_5001_out.png') + with pymupdf.open(path) as document: + page = document[0] + zoom = 0.3 + pixmap = page.get_pixmap(matrix=pymupdf.Matrix(zoom, zoom)) + pixmap.save(path_out) + rms = gentle_compare.pixmaps_rms(path_expected, pixmap) + print() + print(f'test_5001(): {rms=}') + if pymupdf.mupdf_version_tuple >= (1, 28): + assert rms == 0 + else: + assert rms != 0 + wt = pymupdf.TOOLS.mupdf_warnings() + assert wt + +def test_natural(): + if pymupdf.mupdf_version_tuple < (1, 28): + print('test_natural(): Not running because segv fixed on mupdf master (1.28).') + return + path = os.path.normpath(f'{__file__}/../../tests/resources/test_natural.pdf') + with pymupdf.open(path) as document: + page = document[0] + ctm = pymupdf.mupdf.fz_make_matrix(200 / 72, 0, 0, 200 / 72, 0, 0) + rect = pymupdf.mupdf.ll_fz_make_rect(*page.rect) + RGB = pymupdf.mupdf.fz_device_rgb() + GRAY = pymupdf.mupdf.fz_device_gray() + # displaylist = page.get_displaylist() + # print(f"{displaylist=}, {rect=}, {ctm=}, {GRAY=}") + # pm = mupdf.fz_new_pixmap_from_display_list_culling_text2( + pm = pymupdf.mupdf.fz_new_pixmap_from_page_culling_text2( + page, + ctm, + RGB, + 0, + [rect], + ) + pix=pymupdf.Pixmap(pm) + print(f"{pix=}")