pymupdf / PyMuPDF

PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.
https://pymupdf.readthedocs.io
GNU Affero General Public License v3.0
4.49k stars 443 forks source link

Docker python:3.11.6-slim can't build with version 1.24.6 #3619

Open vedeht opened 5 days ago

vedeht commented 5 days ago

Description of the bug

The Dockerfile failed to build because it couldn’t find the make command. This is indicated by the error message /bin/sh: 1: make: not found. The make command is essential for building the MuPDF library from source, which is a dependency for the pymupdf package.

I had to revert to version 1.24.5 to make this work

How to reproduce the bug

     pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: get_mupdf_internal(): out='dir' location=None sha=None
6.266       pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: Download location='https://mupdf.com/downloads/archive/mupdf-1.24.4-source.tar.gz' local_tgz='mupdf-1.24.4-source.tar.gz' name='mupdf-1.24.4-source'
6.266       pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: Downloading from location='https://mupdf.com/downloads/archive/mupdf-1.24.4-source.tar.gz' to local_tgz='mupdf-1.24.4-source.tar.gz'.
6.266       pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: Extracting mupdf-1.24.4-source.tar.gz
6.266       pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: Setting XCFLAGS and XCXXFLAGS to predefine TOFU_CJK_EXT.
6.266       pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: Appending `bsymbolic-` to MuPDF build path.
6.266       pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py: Building MuPDF by running: cd /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source && XCFLAGS=-DTOFU_CJK_EXT XCXXFLAGS=-DTOFU_CJK_EXT /usr/local/bin/python ./scripts/mupdfwrap.py -d build/PyMuPDF-aarch64-shared-tesseract-bsymbolic-release -b all && echo /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source/build/PyMuPDF-aarch64-shared-tesseract-bsymbolic-release: && ls -l /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source/build/PyMuPDF-aarch64-shared-tesseract-bsymbolic-release
6.266       (+0.0s): -b: m: __main__.py:1616:build: Building libmupdf.so ...
6.266       (+0.0s): -b: m: __main__.py:1217:_get_m_command: Setting -j to  multiprocessing.cpu_count()=12
6.266       (+0.0s): -b: m: __main__.py:1618:build: running: cd /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source && XLIB_LDFLAGS=-Wl,-Bsymbolic make -j 12 HAVE_GLUT=no HAVE_PTHREAD=yes verbose=yes shared=yes HAVE_LEPTONICA=yes HAVE_TESSERACT=yes build=release build_prefix=PyMuPDF-aarch64-shared-tesseract-bsymbolic-
6.266       (+0.0s): -b: m: __main__.py:1618:build: (+0.0s): -b: m: __main__.py:1618:build: /bin/sh: 1: make: not found
6.266       (+0.0s): -b: m: __main__.py:1618:build: (+0.0s): -b: m: __main__.py:1618:build:
6.266       (+0.0s): -b: m: __main__.py:1618:build: [returned e=127]
6.266       Traceback (most recent call last):
6.266           scripts/mupdfwrap.py:6:<module>(): wrap.__main__.main()
6.266           scripts/wrap/__main__.py:3092:main(): jlib.exception_info()
6.266           ^except raise:
6.266           scripts/wrap/__main__.py:3090:main(): main2()
6.266           scripts/wrap/__main__.py:2484:main2(): build( build_dirs, swig_command, args, vs_upgrade, make_command)
6.266           scripts/wrap/__main__.py:1618:build(): jlib.system( command, prefix=jlib.log_text(), out='log', verbose=1)
6.266           scripts/jlib.py:1682:system(): raise Exception( message)
6.266       Exception: Command failed: cd /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source && XLIB_LDFLAGS=-Wl,-Bsymbolic make -j 12 HAVE_GLUT=no HAVE_PTHREAD=yes verbose=yes shared=yes HAVE_LEPTONICA=yes HAVE_TESSERACT=yes build=release build_prefix=PyMuPDF-aarch64-shared-tesseract-bsymbolic-
6.266       Traceback (most recent call last):
6.266         File "/usr/local/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
6.266           main()
6.266         File "/usr/local/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
6.266           json_out['return_val'] = hook(**hook_input['kwargs'])
6.266                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6.266         File "/usr/local/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
6.266           whl_basename = backend.build_wheel(metadata_directory, config_settings)
6.266                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6.266         File "/tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/pipcl.py", line 642, in build_wheel
6.266           items = self._call_fn_build(config_settings)
6.266                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6.266         File "/tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/pipcl.py", line 812, in _call_fn_build
6.266           ret = self.fn_build()
6.266                 ^^^^^^^^^^^^^^^
6.266         File "/tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py", line 557, in build
6.266           mupdf_build_dir = build_mupdf_unix( mupdf_local, env_extra, build_type)
6.266                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6.266         File "/tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/setup.py", line 812, in build_mupdf_unix
6.266           subprocess.run( command, shell=True, check=True)
6.266         File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
6.266           raise CalledProcessError(retcode, process.args,
6.266       subprocess.CalledProcessError: Command 'cd /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source && XCFLAGS=-DTOFU_CJK_EXT XCXXFLAGS=-DTOFU_CJK_EXT /usr/local/bin/python ./scripts/mupdfwrap.py -d build/PyMuPDF-aarch64-shared-tesseract-bsymbolic-release -b all && echo /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source/build/PyMuPDF-aarch64-shared-tesseract-bsymbolic-release: && ls -l /tmp/pip-install-h29r5a7v/pymupdf_2fde78ebc24d416e9e82b54a2b4683bb/mupdf-1.24.4-source/build/PyMuPDF-aarch64-shared-tesseract-bsymbolic-release' returned non-zero exit status 1.
6.266       [end of output]
6.266   
6.266   note: This error originates from a subprocess, and is likely not a problem with pip.
6.267 error: metadata-generation-failed
6.267 
6.267 × Encountered error while generating package metadata.
6.267 ╰─> See above for output.
6.267 
6.267 note: This is an issue with the package mentioned above, not pip.
6.267 hint: See above for details.
------
Dockerfile:12
--------------------
  11 |     RUN pip install --upgrade pip
  12 | >>> RUN cd /opt/container \
  13 | >>>     && pip install -r requirements.txt \
  14 | >>>     && useradd bobby \
  15 | >>>     && chown -R bobby:bobby /opt/container \
  16 | >>>     && chown -R bobby:bobby /opt/container/data \
  17 | >>>     && chmod -R 777 /opt/container/data
  18 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c cd /opt/container     && pip install -r requirements.txt     && useradd bobby     && chown -R bobby:bobby /opt/container     && chown -R bobby:bobby /opt/container/data     && chmod -R 777 /opt/container/data" did not complete successfully: exit code: 1

PyMuPDF version

1.24.6

Operating system

Linux

Python version

3.11

julian-smith-artifex-com commented 4 days ago

Usually this would be caused by make not being available inside the docker environment. But if your build works with PyMuPDF-1.24.5, it might not be so simple.

Are you using the same docker image when building the two versions of PyMuPDF? If not, could you try building both PyMuPDF versions in the same docker image?

There is a difference in the make command that is run between PyMuPDF-1.24.5 and PyMuDF-1.24.6 - PyMuDF-1.24.6 prefixes the command with XLIB_LDFLAGS=-Wl,-Bsymbolic. I can't see why this would be a problem. It hasn't ever effected our standard builds and tests, but none of these uses docker.

vedeht commented 4 days ago

I am using the exact same docker image. The only difference is 1.24.5 works and 1.24.6 does not work.

dacodekid commented 3 days ago

For me, the build passed without any issue, but when the container starts, was getting libmupdf.so 24.6 not found and the container fails. Reverting back to 1.24.4 was my only solution.

julian-smith-artifex-com commented 3 days ago

Could you try building with PYMUPDF_SETUP_MUPDF_BSYMBOLIC=0 ?

This will omit the new XLIB_LDFLAGS=-Wl,-Bsymbolic setting, making the make command more similar to that used by version 1.24.4.