Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- "centos-stream-8-amd64"
- "debian-10-buster-x86"
- "fedora-34-amd64"
- "manylinux1-wheel-build"
- "manylinux2014-wheel-build"
- "ubuntu-18.04-bionic-amd64"
- "ubuntu-20.04-focal-amd64"
- "ubuntu-20.04-focal-amd64-valgrind"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TARGETS = \
centos-stream-8-amd64 \
debian-10-buster-x86 \
fedora-34-amd64 \
manylinux1-wheel-build \
manylinux2014-wheel-build \
ubuntu-18.04-bionic-amd64 \
ubuntu-20.04-focal-amd64 \
ubuntu-20.04-focal-amd64-valgrind \
Expand Down
23 changes: 23 additions & 0 deletions manylinux2014-wheel-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM quay.io/pypa/manylinux2014_x86_64:latest

run mkdir /src && mkdir /Pillow
ENV SRC=/src
ENV PATH=/opt/rh/devtoolset-2/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN git clone --depth 1 https://github.com/python-pillow/pillow-wheels /src/pillow-wheels

COPY build_depends.sh /src
copy yum_install /usr/local/bin

RUN cd $SRC/pillow-wheels \
&& git submodule update --init multibuild \
&& bash $SRC/build_depends.sh


FROM quay.io/pypa/manylinux2014_x86_64:latest
COPY --from=0 /usr/local/lib /usr/local/lib
COPY --from=0 /usr/local/include /usr/local/include
RUN yum install -y zlib-devel
COPY build.sh /build.sh

CMD ["/bin/sh /build.sh"]
46 changes: 46 additions & 0 deletions manylinux2014-wheel-build/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
WD = $(shell pwd)
USERNAME := $(shell docker info | grep Username | xargs | cut -d ' ' -f 2)
TARGET := $(notdir $(WD))
ROOT := $(abspath $(WD)/../Pillow)
IMAGENAME := $(if $(USERNAME), $(USERNAME)/$(TARGET), $(TARGET))
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
TEST_TARGET = ubuntu-20.04-focal-amd64
TEST_IMAGE=pythonpillow/$(TEST_TARGET)
.PHONY: build
build:
docker build -t $(IMAGENAME):$(BRANCH) .

.PHONY: update
update:
./update.sh

.PHONY: wheel
wheel:
-[ ! -d out ] && mkdir out
docker run --rm -v $(ROOT):/Pillow -v `pwd`/out:/output $(IMAGENAME):$(BRANCH) /build.sh $(_PYVER)

37:
_PYVER=37 $(MAKE) wheel
38:
_PYVER=38 $(MAKE) wheel
39:
_PYVER=39 $(MAKE) wheel
310:
_PYVER=310 $(MAKE) wheel

.PHONY: test
test: 38
docker run --rm -v $(ROOT):/Pillow -v `pwd`/out:/output $(TEST_IMAGE):$(BRANCH) sh -c "/vpy3/bin/pip install /output/*cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl && cd /Pillow && /vpy3/bin/python selftest.py && /usr/bin/xvfb-run -a /vpy3/bin/pytest -vx"

.PHONY: push
push:
docker push $(IMAGENAME):$(BRANCH)

.PHONY: clean
clean:
-rm -r out

.PHONY: shell
shell:
docker run --rm -it -v $(ROOT):/Pillow $(IMAGENAME):$(BRANCH) /bin/bash

35 changes: 35 additions & 0 deletions manylinux2014-wheel-build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Wheel Builder image

This image is a little different than the other images in this repo --
it's intended to be a quick way to build manylinux wheels with the
production version of the libraries for debugging and testing
purposes. This is designed to work as a single Docker image that
doesn't require privilege or multiple images to run.

Like the other images in this repo, it expects that there is a Pillow
source directory mounted at /Pillow. Unlike the others, it puts the
output files in /output. This should be mounted as a volume to the host
to retrieve the finished wheel.

Setting the environment variable `DEBUG=1` will create a build with
symbols for debugging with Valgrind/GDB.

The Makefile has several new commands:

* make wheel: Makes a Python 3.8 manylinux2014 wheel, and puts it in the
./out directory.
* make 37|38|39|310: These are specific commands to make
the corresponding 3.x version in the ./out directory.

The test target here is mainly to validate the image build, it is
assumed that the builds will be used for other purposes or tested in
other images.


# Sources

* build_depends is from our integration with OSS-Fuzz
* yum_install is syntactic sugar to make the multibuild repo work with
the base manylinux wheel image, rather than with its custom set of
images

32 changes: 32 additions & 0 deletions manylinux2014-wheel-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh -eu

# options required to trigger the vendored Raqm install
OPTS="--global-option build_ext --global-option --vendor-raqm --global-option --vendor-fribidi"

CFLAGS=${CFLAGS:-}
export CFLAGS="$CFLAGS --std=c99"

# Check for debug build
DEBUG=${DEBUG:-0}
if [ $DEBUG ]; then
OPTS="--global-option build --global-option --debug $OPTS"
CFLAGS="$CFLAGS -Og -DDEBUG"
fi

# not strictly necessary, unless running multiple versions from the shell
rm -f /tmp/*.whl || true

# Python version, as 37,38,39,310. Defaults to 38.
# Matches the naming in /opt/python/
PYVER=${1:-38}
PYBIN=$(echo /opt/python/cp${PYVER}*/bin)

# We have to clean up the Pillow directories, otherwise we might get
# cached builds that are not manylinux wheel compatible
cd /Pillow
PATH=$PYBIN:$PATH make clean

# Build and repair
$PYBIN/pip --verbose wheel ${OPTS} -w /tmp /Pillow
$PYBIN/pip install "auditwheel<5"
$PYBIN/python3 -m auditwheel repair /tmp/Pillow*whl -w /output
30 changes: 30 additions & 0 deletions manylinux2014-wheel-build/build_depends.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


. multibuild/common_utils.sh

export CONFIGURE_BUILD_SOURCED=1
BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"
export CPPFLAGS="-I$BUILD_PREFIX/include $CPPFLAGS"
export LIBRARY_PATH="$BUILD_PREFIX/lib:$LIBRARY_PATH"
export PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig/:$PKG_CONFIG_PATH"

. multibuild/library_builders.sh
. config.sh

yum install -y gcc gcc-c++
pre_build
2 changes: 2 additions & 0 deletions manylinux2014-wheel-build/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
docker pull quay.io/pypa/manylinux2014_x86_64:latest
3 changes: 3 additions & 0 deletions manylinux2014-wheel-build/yum_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

yum install -y $@