Repository navigation
Conversation
|
Validated that it does not mess up a so Ubuntu 24.04 normy build: docker run --rm -v /tmp/repro:/src -w /src ubuntu:24.04 bash -lc '
set -eux
rm -rf build src/pillow.egg-info
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential python3-dev python3-venv python3-pip pkg-config libtiff-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libopenjp2-7-dev libimagequant-dev libraqm-dev libxcb1-dev binutils file ca-certificates
python3 -m venv /tmp/pillow-pr9635-venv
/tmp/pillow-pr9635-venv/bin/python -m pip install -U pip setuptools wheel pybind11
MAX_CONCURRENCY=2 /tmp/pillow-pr9635-venv/bin/python -m pip install -v --no-build-isolation --no-cache-dir .
so=$(/tmp/pillow-pr9635-venv/bin/python -c "import PIL._imaging, pathlib; print(pathlib.Path(PIL._imaging.__file__))")
printf "SO=%s\n" "$so"
/tmp/pillow-pr9635-venv/bin/python -c "from PIL import features; import PIL, pathlib; print(\"Pillow\", PIL.__version__); print(\"libtiff feature\", features.check(\"libtiff\")); print(\"libtiff version\", features.version(\"libtiff\")); print(\"PIL package\", pathlib.Path(PIL.__file__).parent)"
file "$so"
readelf -d "$so" | egrep "NEEDED|RPATH|RUNPATH" || true
ldd "$so" | egrep "tiff|jpeg|z|lzma|zstd|webp|jbig|deflate|not found" || true
' |
|
@radarhere who can help pull this over the finish line? are you able to merge it with main/master? |
|
Did you have any thoughts on our conversation in #9615? |
|
I've fixed the test image below so it reproduces my original failure exactly. The changes versus the version I posted in #9615:
FROM alpine:latest AS builder
RUN apk add --no-cache \
build-base pkgconf zlib-dev zstd-dev xz-dev curl
ENV TIFF_VERSION=4.7.1
RUN curl -fsSL "https://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz" \
| tar xz -C /tmp && mv /tmp/tiff-* /tmp/libtiff
WORKDIR /tmp/libtiff
RUN mkdir -p _build && cd _build \
&& ../configure \
--prefix=/usr/local \
--disable-shared --enable-static --with-pic \
--disable-docs --disable-tools --disable-tests \
--disable-contrib --disable-libdeflate \
--disable-lerc --disable-jbig --disable-cxx \
--disable-webp --disable-lzma \
&& make -j"$(nproc)" && make install
FROM alpine:latest
RUN apk add --no-cache \
pkgconf build-base python3-dev py3-pip linux-headers binutils \
zlib-dev zstd-dev xz-dev libjpeg-turbo-dev
COPY --from=builder /usr/local/lib/libtiff.a /usr/local/lib/
COPY --from=builder /usr/local/include/ /usr/local/include/
COPY --from=builder /usr/local/lib/pkgconfig/ /usr/local/lib/pkgconfig/
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
WORKDIR /src
COPY . /src
RUN python3 -m venv /venv \
&& /venv/bin/pip install --no-cache-dir pybind11 setuptools wheel \
&& (/venv/bin/pip install --no-build-isolation . > /build.log 2>&1 || true)
CMD ["/venv/bin/python", "-c", "import PIL._imaging; print('IMPORT_OK')"]On this PR this works. Build and import should print |
for more information, see https://pre-commit.ci
Bear with me if this is a silly question, but is this necessary? |
|
LZMA is just doing what it likely should be doing: https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
The easy thing is to just pass on all things pkg-config tells us is related to compilation. The hard thing is to start filtering away things. But then again, before this PR, all things were thrown away and static linking was broken. Pillow and libtiff seems to work both with |
What changed
This updates the Pillow source build to include libtiff's pkg-config static link dependencies when the detected TIFF library is an archive.
For dynamic libtiff builds, behavior is unchanged. For static-only libtiff builds, Pillow now reads
pkg-config --libs --staticfor the libtiff module that resolvedTIFF_ROOT, adds its-Ldirectories, appends private-ldependencies after-ltiff, and passes through other linker flags such as-pthread.Why
On systems with
/usr/lib/libtiff.abut nolibtiff.so, Pillow previously linkedPIL._imagingwith-ltiff -ljpeg -lzonly. The build succeeded, but importingPIL._imagingfailed with unresolved libtiff private dependency symbols such asZSTD_compressStream.Addresses #9615.
Validation
Reproduced before the fix on a host with:
/usr/lib/libtiff.alibtiff.so*pkg-config --libs libtiff-4->-ltiffpkg-config --libs --static libtiff-4->-ltiff -lzstd -lm -lzstd -llzma -pthread -lpthread -ljpeg -lzAfter the fix:
MAX_CONCURRENCY=1 python -m pip install -v --no-build-isolation -C tiff=enable .python -c "import PIL._imaging"python selftest.py-> 59 tests passed