Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21.0: test_textbox3 fails when built against system libmupdf (1.21.0) #2040

Closed
dvzrv opened this issue Nov 10, 2022 · 3 comments
Closed

1.21.0: test_textbox3 fails when built against system libmupdf (1.21.0) #2040

dvzrv opened this issue Nov 10, 2022 · 3 comments

Comments

@dvzrv
Copy link

dvzrv commented Nov 10, 2022

Please provide all mandatory information!

Describe the bug (mandatory)

A clear and concise description of what the bug is.

To Reproduce (mandatory)

Patch setup.py (see #2039).

  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  local _test_dir="test_dir"

  cd $_name-$pkgver
  export PYMUPDF_SETUP_MUPDF_BUILD=""
  python -m build --wheel --no-isolation
  mkdir -vp $_test_dir
  # install to test dir for testing
  python -m installer --destdir="$_test_dir" dist/*.whl

  export PYTHONPATH="$_test_dir/$_site_packages:$PYTHONPATH"
  # pytest -vv -c /dev/null tests/ -k 'not test_textbox3'
  pytest -vv -c /dev/null tests/
=================================== FAILURES ===================================
________________________________ test_textbox3 _________________________________

    def test_textbox3():
        """Use TextWriter for text insertion."""
        doc = fitz.open()
        page = doc.new_page()
        font = fitz.Font("cjk")
        rect = fitz.Rect(50, 50, 400, 400)
        blue = (0, 0, 1)
        tw = fitz.TextWriter(page.rect, color=blue)
>       tw.fill_textbox(
            rect,
            text,
            align=fitz.TEXT_ALIGN_LEFT,
            font=font,
            fontsize=12,
            right_to_left=True,
        )

tests/test_textbox.py:66:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_dir/usr/lib/python3.10/site-packages/fitz/utils.py:4408: in fill_textbox
    append_this(start, line)
test_dir/usr/lib/python3.10/site-packages/fitz/utils.py:4237: in append_this
    return writer.append(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <fitz.fitz.TextWriter; proxy of <Swig Object of type 'TextWriter *' at 0x60af743f6a60> >
pos = Point(52.400001525878906, 778.18798828125)
text = 'auch crassidens), (Pseudorca Schwertwal Kleine Der'
font = Font('Source Han Serif TC Regular'), fontsize = 12, language = None
right_to_left = 0, small_caps = False

    def append(self, pos, text, font=None, fontsize=11, language=None, right_to_left=0, small_caps=0):

        """Store 'text' at point 'pos' using 'font' and 'fontsize'."""

        pos = Point(pos) * self.ictm
        if font is None:
            font = Font("helv")
        if not font.is_writable:
>           raise ValueError("Unsupported font '%s'." % font.name)
E           ValueError: Unsupported font 'Source Han Serif TC Regular'.

test_dir/usr/lib/python3.10/site-packages/fitz/fitz.py:8613: ValueError
=============================== warnings summary ===============================
../../../../usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:433
  /usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:433: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/nodeids
    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))

../../../../usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:387
  /usr/lib/python3.10/site-packages/_pytest/cacheprovider.py:387: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/lastfailed
    config.cache.set("cache/lastfailed", self.lastfailed)

../../../../usr/lib/python3.10/site-packages/_pytest/stepwise.py:52
  /usr/lib/python3.10/site-packages/_pytest/stepwise.py:52: PytestCacheWarning: could not create cache path /dev/.pytest_cache/v/cache/stepwise
    session.config.cache.set(STEPWISE_CACHE_DIR, [])

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED ../../../../dev/test_textbox.py::test_textbox3 - ValueError: Unsupport...
============= 1 failed, 92 passed, 1 skipped, 3 warnings in 2.08s ==============

Full build and test logs:
python-pymupdf-1.21.0-1-x86_64-build.log
python-pymupdf-1.21.0-1-x86_64-check.log

Expected behavior (optional)

All tests pass successfully.

Screenshots (optional)

n/a

Your configuration (mandatory)

  • Arch Linux
  • Python 3.10.8, x86_64
  • PyMuPDF 1.21.0 source -> wheel -> package createion

Additional context (optional)

The test does not fail when the bundled sources are being built.

archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Nov 10, 2022
Add patch for setup.py to be able to build against system libmupdf.
pymupdf/PyMuPDF#2039
Disable broken test: pymupdf/PyMuPDF#2040

git-svn-id: file:///srv/repos/svn-community/svn@1346428 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Nov 10, 2022
Add patch for setup.py to be able to build against system libmupdf.
pymupdf/PyMuPDF#2039
Disable broken test: pymupdf/PyMuPDF#2040

git-svn-id: file:///srv/repos/svn-community/svn@1346428 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@julian-smith-artifex-com
Copy link
Collaborator

Thanks for reporting this.

We're looking into whether it might be possible to make test_textbox3() do nothing if it can tell that mudf was built without TOFU_CJK_EXT being defined, but this looks like it will require a change to mupdf itself.

In the meantime we might add some text to the documentation recommending your use of pytest -k 'not test_textbox3' if testing with a non-default mupdf build.

julian-smith-artifex-com added a commit to ArtifexSoftware/PyMuPDF-julian that referenced this issue Nov 21, 2022
Also mention exclusion of test_textbox3() with non-standard MuPDF; this
partially addresses pymupdf#2040.
julian-smith-artifex-com added a commit to ArtifexSoftware/PyMuPDF-julian that referenced this issue Nov 21, 2022
Also mention exclusion of test_textbox3() with non-standard MuPDF; this
partially addresses pymupdf#2040.
julian-smith-artifex-com added a commit that referenced this issue Nov 21, 2022
Also mention exclusion of test_textbox3() with non-standard MuPDF; this
partially addresses #2040.
@julian-smith-artifex-com
Copy link
Collaborator

This issue is documented in PyMuPDF-1.21.1.

NB we have a plan to make future releases use MuPDF's default config, which will fix this issue.

@dvzrv
Copy link
Author

dvzrv commented Apr 17, 2023

This seems to be fixed with 1.22.0 (mupdf/pymupdf)

@dvzrv dvzrv closed this as completed Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants