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.51k stars 445 forks source link

Add Wheel for ARM musllinux aarch64 #3541

Open quinnjr opened 1 month ago

quinnjr commented 1 month ago

Is your feature request related to a problem? Please describe. Currently, this library takes forever to compile on Alpine Linux for Docker containers running on ARM. Please cross-compile the library for arm64 with support for Alpine Linux.

Describe the solution you'd like A new wheel is added that installs the library for Alpine Linux without burdensome compilation.

Describe alternatives you've considered Alternatively, Alpine Linux has MuPDF as an installable library. Instead, use the system library instead of downloading it as an addition of the install.

julian-smith-artifex-com commented 3 weeks ago

[Making PyMuPDF use an installed MuPDF is non-trivial because we require MuPDF's Python bindings, which are probably not installed.]

I have an experimental PyMuPDF musllinux wheel at: http://ghostscript.com/~julian/PyMuPDF-1.24.5-cp312-none-musllinux_1_2_x86_64.whl

I've no idea whether it will work on Alpine Linux, but if you could try it out that would be appreciated. For example:

wget http://ghostscript.com/~julian/PyMuPDF-1.24.5-cp312-none-musllinux_1_2_x86_64.whl
pip install PyMuPDF-1.24.5-cp312-none-musllinux_1_2_x86_64.whl

[I can build for a different Python version if required.]

julian-smith-artifex-com commented 3 weeks ago

Apologies, the wheel above is for x86_64, not aarch64.

Unfortunately building for musllinux aarch64 on Github does not work because the Python libclang package appears to be broken - it cannot find libclang.so at runtime.

If you have a working build (even if very slow), could you give details of the system?

quinnjr commented 3 weeks ago

I'm currently running the following Docker container and copying the completed wheel out of it for install. Haven't had much time recently to test full compatibility due to work crunch (not detecting its building for musl linux).

FROM --platform=arm64 alpine:latest

RUN apk update && apk add python3 py3-pip py3-wheel musl-dev jpeg-dev zlib-dev freetype-dev clang clang-dev llvm m4 cmake python3-dev build-base swig

ENV VERSION=1.24.5

WORKDIR /tmp

RUN <<EOF
  pip install --break-system-packages libclang
  wget https://github.com/pymupdf/PyMuPDF/archive/refs/tags/$VERSION.tar.gz
  tar -xvf $VERSION.tar.gz
  cd PyMuPDF-$VERSION
  PYMUPDF_SETUP_MUPDF_TESSERACT=0 python3 setup.py bdist_wheel
EOF

WORKDIR /project
docker build -t pymupdf .
docker run -v $(pwd):/project -it pymupdf

cp /tmp/PyMuPDF-1.24.5/dist/PyMuPDF-1.24.5-cp312-none-linux_aarch64.whl /project
julian-smith-artifex-com commented 3 weeks ago

Do you know why this uses --break-system-packages in the command pip install --break-system-packages libclang?

This looks like it might be working around the problem that i'm seeing.

quinnjr commented 3 weeks ago

py3-libclang isn't available in the Alpine repos so I'm installing it as a system package.

-------- Original Message -------- On 6/8/24 1:22 PM, Julian Smith wrote:

Do you know why this uses --break-system-packages in the command pip install --break-system-packages libclang?

This looks like it might be working around the problem that i'm seeing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>