Skip to content

Support building docker image from M1 Mac #1562

Closed
@NixBiks

Description

@NixBiks

Is your feature request related to a problem? Please describe.

I'm trying to build a docker container with PyMuPDF but unfortunately I can't get it to work on my Mac M1.

Describe the solution you'd like

My Dockerfile looks like this

FROM python:3.10-bullseye
RUN apt-get update && apt-get install --no-install-recommends -y mupdf
RUN pip3 install --upgrade pip
RUN pip3 install pymupdf

When I run docker build . then I get the following error

#7 0.558 Collecting pymupdf                                                                                                                                            
#7 0.750   Downloading PyMuPDF-1.19.4.tar.gz (2.3 MB)                                                                                                                  
#7 0.955   Preparing metadata (setup.py): started                                                                                                                      
#7 1.134   Preparing metadata (setup.py): finished with status 'done'                                                                                                  
#7 1.135 Building wheels for collected packages: pymupdf
#7 1.136   Building wheel for pymupdf (setup.py): started
#7 1.294   Building wheel for pymupdf (setup.py): finished with status 'error'
#7 1.294   ERROR: Command errored out with exit status 1:
#7 1.294    command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rdtyj0dj
#7 1.294        cwd: /tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/
#7 1.294   Complete output (20 lines):
#7 1.294   running bdist_wheel
#7 1.294   running build
#7 1.294   running build_py
#7 1.294   creating build
#7 1.294   creating build/lib.linux-aarch64-3.10
#7 1.294   creating build/lib.linux-aarch64-3.10/fitz
#7 1.294   copying fitz/__init__.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.294   copying fitz/fitz.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.294   copying fitz/utils.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.294   copying fitz/__main__.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.294   running build_ext
#7 1.294   building 'fitz._fitz' extension
#7 1.294   creating build/temp.linux-aarch64-3.10
#7 1.294   creating build/temp.linux-aarch64-3.10/fitz
#7 1.294   gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -Imupdf/thirdparty/freetype/include -I/usr/include/freetype2 -I/usr/local/include/python3.10 -c fitz/fitz_wrap.c -o build/temp.linux-aarch64-3.10/fitz/fitz_wrap.o
#7 1.294   fitz/fitz_wrap.c:2755:10: fatal error: fitz.h: No such file or directory
#7 1.294    2755 | #include <fitz.h>
#7 1.294         |          ^~~~~~~~
#7 1.294   compilation terminated.
#7 1.294   error: command '/usr/bin/gcc' failed with exit code 1
#7 1.294   ----------------------------------------
#7 1.294   ERROR: Failed building wheel for pymupdf
#7 1.294   Running setup.py clean for pymupdf
#7 1.375 Failed to build pymupdf
#7 1.386 Installing collected packages: pymupdf
#7 1.387     Running setup.py install for pymupdf: started
#7 1.517     ERROR: Command errored out with exit status 1:
#7 1.517      command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-h77owsa2/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.10/pymupdf
#7 1.517          cwd: /tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/
#7 1.517     Complete output (20 lines):
#7 1.517     running install
#7 1.517     running build
#7 1.517     running build_py
#7 1.517     creating build
#7 1.517     creating build/lib.linux-aarch64-3.10
#7 1.517     creating build/lib.linux-aarch64-3.10/fitz
#7 1.517     copying fitz/__init__.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.517     copying fitz/fitz.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.517     copying fitz/utils.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.517     copying fitz/__main__.py -> build/lib.linux-aarch64-3.10/fitz
#7 1.517     running build_ext
#7 1.517     building 'fitz._fitz' extension
#7 1.517     creating build/temp.linux-aarch64-3.10
#7 1.517     creating build/temp.linux-aarch64-3.10/fitz
#7 1.517     gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -Imupdf/thirdparty/freetype/include -I/usr/include/freetype2 -I/usr/local/include/python3.10 -c fitz/fitz_wrap.c -o build/temp.linux-aarch64-3.10/fitz/fitz_wrap.o
#7 1.517     fitz/fitz_wrap.c:2755:10: fatal error: fitz.h: No such file or directory
#7 1.517      2755 | #include <fitz.h>
#7 1.517           |          ^~~~~~~~
#7 1.517     compilation terminated.
#7 1.517     error: command '/usr/bin/gcc' failed with exit code 1
#7 1.517     ----------------------------------------
#7 1.517     Running setup.py install for pymupdf: finished with status 'error'
#7 1.517 ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7ttde7if/pymupdf_5e778e7ede114e88a541cb42ff556098/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-h77owsa2/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.10/pymupdf Check the logs for full command output.

Additional context
I've also questioned this in this closed thread but I thought it was better to start a new issue instead.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions