1+ #! /bin/bash
12# Define custom utilities
23# Test for macOS with [ -n "$IS_MACOS" ]
4+ if [ -z " $IS_MACOS " ]; then
5+ export MB_ML_LIBC=${AUDITWHEEL_POLICY:: 9}
6+ export MB_ML_VER=${AUDITWHEEL_POLICY: 9}
7+ fi
8+ export PLAT=$CIBW_ARCHS
9+ source wheels/multibuild/common_utils.sh
10+ source wheels/multibuild/library_builders.sh
11+ if [ -z " $IS_MACOS " ]; then
12+ source wheels/multibuild/manylinux_utils.sh
13+ fi
314
415ARCHIVE_SDIR=pillow-depends-main
516
@@ -27,9 +38,9 @@ BZIP2_VERSION=1.0.8
2738LIBXCB_VERSION=1.16
2839BROTLI_VERSION=1.1.0
2940
30- if [[ -n " $IS_MACOS " ]] && [[ " $PLAT " == " x86_64" ]]; then
41+ if [[ -n " $IS_MACOS " ]] && [[ " $CIBW_ARCHS " == " x86_64" ]]; then
3142 function build_openjpeg {
32- local out_dir=$( fetch_unpack https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION} .tar.gz)
43+ local out_dir=$( fetch_unpack https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION} .tar.gz openjpeg-2.5.0.tar.gz )
3344 (cd $out_dir \
3445 && cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX /lib . \
3546 && make install)
3950
4051function build_brotli {
4152 local cmake=$( get_modern_cmake)
42- local out_dir=$( fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION .tar.gz)
53+ local out_dir=$( fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION .tar.gz brotli-1.1.0.tar.gz )
4354 (cd $out_dir \
4455 && $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX /lib . \
4556 && make install)
@@ -49,12 +60,7 @@ function build_brotli {
4960 fi
5061}
5162
52- function pre_build {
53- # Any stuff that you need to do before you start building the wheels
54- # Runs in the root directory of this repository.
55- curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
56- untar pillow-depends-main.zip
57-
63+ function build {
5864 build_xz
5965 if [ -z " $IS_ALPINE " ] && [ -z " $IS_MACOS " ]; then
6066 yum remove -y zlib-devel
@@ -114,74 +120,36 @@ function pre_build {
114120 fi
115121 build_simple harfbuzz $HARFBUZZ_VERSION https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION tar.xz --with-freetype=yes --with-glib=no
116122 if [ -z " $IS_MACOS " ]; then
117- export FREETYPE_LIBS=' '
118- export FREETYPE_CFLAGS=' '
123+ export FREETYPE_LIBS=" "
124+ export FREETYPE_CFLAGS=" "
119125 fi
120-
121- # Append licenses
122- for filename in wheels/dependency_licenses/* ; do
123- echo -e " \n\n----\n\n$( basename $filename | cut -f 1 -d ' .' ) \n" | cat >> LICENSE
124- cat $filename >> LICENSE
125- done
126126}
127127
128- function pip_wheel_cmd {
129- local abs_wheelhouse=$1
130- if [ -z " $IS_MACOS " ]; then
131- CFLAGS=" $CFLAGS --std=c99" # for Raqm
132- fi
133- python3 -m pip wheel $( pip_opts) \
134- -C raqm=enable -C raqm=vendor -C fribidi=vendor \
135- -w $abs_wheelhouse --no-deps .
136- }
128+ # Any stuff that you need to do before you start building the wheels
129+ # Runs in the root directory of this repository.
130+ curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
131+ untar pillow-depends-main.zip
137132
138- function run_tests_in_repo {
139- # Run Pillow tests from within source repo
140- python3 selftest.py
141- python3 -m pytest
142- }
133+ if [[ -n " $IS_MACOS " ]]; then
134+ # webp, zstd, xz, libtiff, libxcb cause a conflict with building webp, libtiff, libxcb
135+ # libxdmcp causes an issue on macOS < 11
136+ # curl from brew requires zstd, use system curl
137+ # if php is installed, brew tries to reinstall these after installing openblas
138+ # remove cairo to fix building harfbuzz on arm64
139+ # remove lcms2 and libpng to fix building openjpeg on arm64
140+ brew remove --ignore-dependencies webp zstd xz libpng libtiff libxcb libxdmcp curl php cairo lcms2 ghostscript
141+
142+ brew install pkg-config
143+
144+ if [[ " $CIBW_ARCHS " != " arm64" ]]; then
145+ export MACOSX_DEPLOYMENT_TARGET=" 10.10"
146+ fi
147+ fi
143148
144- EXP_CODECS=" jpg jpg_2000 libtiff zlib"
145- EXP_MODULES=" freetype2 littlecms2 pil tkinter webp"
146- EXP_FEATURES=" fribidi harfbuzz libjpeg_turbo raqm transp_webp webp_anim webp_mux xcb"
149+ wrap_wheel_builder build
147150
148- function run_tests {
149- if [ -n " $IS_MACOS " ]; then
150- brew install fribidi
151- export PKG_CONFIG_PATH=" /usr/local/opt/openblas/lib/pkgconfig"
152- elif [ -n " $IS_ALPINE " ]; then
153- apk add curl fribidi
154- else
155- apt-get update
156- apt-get install -y curl libfribidi0 libopenblas-dev pkg-config unzip
157- fi
158- if [ -z " $IS_ALPINE " ]; then
159- python3 -m pip install numpy
160- fi
161- python3 -m pip install defusedxml olefile pyroma
162-
163- curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip
164- untar pillow-test-images.zip
165- mv test-images-main/* ../Tests/images
166-
167- # Runs tests on installed distribution from an empty directory
168- (cd .. && run_tests_in_repo)
169- # Test against expected codecs, modules and features
170- local ret=0
171- local codecs=$( python3 -c ' from PIL.features import *; print(" ".join(sorted(get_supported_codecs())))' )
172- if [ " $codecs " != " $EXP_CODECS " ]; then
173- echo " Codecs should be: '$EXP_CODECS '; but are '$codecs '"
174- ret=1
175- fi
176- local modules=$( python3 -c ' from PIL.features import *; print(" ".join(sorted(get_supported_modules())))' )
177- if [ " $modules " != " $EXP_MODULES " ]; then
178- echo " Modules should be: '$EXP_MODULES '; but are '$modules '"
179- ret=1
180- fi
181- local features=$( python3 -c ' from PIL.features import *; print(" ".join(sorted(get_supported_features())))' )
182- if [ " $features " != " $EXP_FEATURES " ]; then
183- echo " Features should be: '$EXP_FEATURES '; but are '$features '"
184- ret=1
185- fi
186- return $ret
187- }
151+ # Append licenses
152+ for filename in wheels/dependency_licenses/* ; do
153+ echo -e " \n\n----\n\n$( basename $filename | cut -f 1 -d ' .' ) \n" | cat >> LICENSE
154+ cat $filename >> LICENSE
155+ done
0 commit comments