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.1: test_color_count fails #2127

Closed
dvzrv opened this issue Dec 15, 2022 · 6 comments
Closed

1.21.1: test_color_count fails #2127

dvzrv opened this issue Dec 15, 2022 · 6 comments

Comments

@dvzrv
Copy link

dvzrv commented Dec 15, 2022

Please provide all mandatory information!

Describe the bug (mandatory)

test_color_count fails

To Reproduce (mandatory)

  export PYMUPDF_SETUP_MUPDF_BUILD=""
  python -m build --wheel --no-isolation

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

  cd $_name-$pkgver
  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"
  # disable broken test: https://github.com/pymupdf/PyMuPDF/issues/2040
  pytest -vv -c /dev/null tests/ -k 'not test_textbox3'
=================================== FAILURES ===================================
_______________________________ test_color_count _______________________________

    def test_color_count():
        pm = fitz.Pixmap(imgfile)
>       assert pm.color_count() == 40624
E       assert 39912 == 40624
E        +  where 39912 = <bound method Pixmap.color_count of Pixmap(DeviceRGB, IRect(0, 0, 439, 501), 0)>()
E        +    where <bound method Pixmap.color_count of Pixmap(DeviceRGB, IRect(0, 0, 439, 501), 0)> = Pixmap(DeviceRGB, IRect(0, 0, 439, 501), 0).color_count

tests/test_pixmap.py:94: AssertionError
=============================== 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_pixmap.py::test_color_count - assert 39912 == 40624
====== 1 failed, 95 passed, 1 skipped, 1 deselected, 3 warnings in 1.65s =======

python-pymupdf-1.21.1-1-x86_64-build.log
python-pymupdf-1.21.1-1-x86_64-check.log

Expected behavior (optional)

All tests pass.

Screenshots (optional)

n/a

Your configuration (mandatory)

  • Arch Linux
  • Python 3.10.8
  • PyMuPDF 1.21.1 from tarball

Additional context (optional)

n/a

archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Dec 15, 2022
Remove unneeded patch for building against system libs.
Disable test_color_count: pymupdf/PyMuPDF#2127

git-svn-id: file:///srv/repos/svn-community/svn@1359226 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this issue Dec 15, 2022
Remove unneeded patch for building against system libs.
Disable test_color_count: pymupdf/PyMuPDF#2127

git-svn-id: file:///srv/repos/svn-community/svn@1359226 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@JorjMcKie
Copy link
Collaborator

I just confirmed:

python -m pytest test_pixmap.py

works for Windows and Linux Ubuntu for v1.21.1.

@julian-smith-artifex-com
Copy link
Collaborator

PYMUPDF_SETUP_MUPDF_BUILD="" means PyMuPDF is built with your system's installed MuPDF, over which we have no control.

Different releases of MuPDF behave slightly differently. And it is already known that some system MuPDF builds break tests/test_textbox.py:test_textbox3() because of not being built with PyMuPDF's customised config file (this is #2040).

So i don't think we can do anything about this issue.

Perhaps if we knew exactly what version of mupdf is installed, and exactly how it was built, this might be useful information, but ultimately the solution here is to build PyMuPDF with the hard-coded default version of MuPDF with which it is tested, and which is used when building PyMuPDF sdist and wheels for release.

@julian-smith-artifex-com
Copy link
Collaborator

Closing this as it's not something that we can fix in PyMuPDF.

@dvzrv
Copy link
Author

dvzrv commented Apr 17, 2023

This still fails with 1.22.0 (both mupdf and pymupdf), which is what you are using in the bundled sources as well. So I believe this issue can not be dismissed like that.
FWIW: The system-wide version of mupdf that I built against in previous versions usually closely matches the bundled one (as the same version is usually used).

@julian-smith-artifex-com
Copy link
Collaborator

Was your system-wide mupdf built using its original include/mupdf/fitz/config.h?

Unfortunately the only way that we can reliably pass all tests at the moment is if PyMuPDF is using an MuPDF that has been built with its include/mupdf/fitz/config.h replaced by PyMuPDF's fitz/_config.h.

[This situation is not ideal. We are hoping to change PyMuPDF so it does not change MuPDF's at build time, but this causes some subtle changes in behaviour.]

@dvzrv
Copy link
Author

dvzrv commented Apr 17, 2023

Was your system-wide mupdf built using its original include/mupdf/fitz/config.h?

yep, I don't think that has been changed. Here is the PKGBUILD for it: https://github.com/archlinux/svntogit-community/blob/packages/mupdf/trunk/PKGBUILD

Unfortunately the only way that we can reliably pass all tests at the moment is if PyMuPDF is using an MuPDF that has been built with its include/mupdf/fitz/config.h replaced by PyMuPDF's fitz/_config.h.

[This situation is not ideal. We are hoping to change PyMuPDF so it does not change MuPDF's at build time, but this causes some subtle changes in behaviour.]

Ah, that would explain it I guess.
That is not something we can (or would want to) cater to in system's packaging, as it means introducing a circular dependency between pymupdf and mupdf (in a packaging context).
I'll just disable the test for now until you have found a way to build it without modifications :)

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

3 participants