2023-11-14 15:23:46 +03:00
|
|
|
#!/bin/bash
|
2016-06-20 21:30:30 +03:00
|
|
|
# Define custom utilities
|
2021-01-10 14:19:26 +03:00
|
|
|
# Test for macOS with [ -n "$IS_MACOS" ]
|
2023-11-14 15:23:46 +03:00
|
|
|
if [ -z "$IS_MACOS" ]; then
|
|
|
|
export MB_ML_LIBC=${AUDITWHEEL_POLICY::9}
|
|
|
|
export MB_ML_VER=${AUDITWHEEL_POLICY:9}
|
|
|
|
fi
|
|
|
|
export PLAT=$CIBW_ARCHS
|
|
|
|
source wheels/multibuild/common_utils.sh
|
|
|
|
source wheels/multibuild/library_builders.sh
|
|
|
|
if [ -z "$IS_MACOS" ]; then
|
|
|
|
source wheels/multibuild/manylinux_utils.sh
|
|
|
|
fi
|
2016-06-20 21:30:30 +03:00
|
|
|
|
2021-10-15 16:02:27 +03:00
|
|
|
ARCHIVE_SDIR=pillow-depends-main
|
2018-07-03 12:41:06 +03:00
|
|
|
|
2016-07-31 23:09:20 +03:00
|
|
|
# Package versions for fresh source builds
|
2023-08-26 06:26:05 +03:00
|
|
|
FREETYPE_VERSION=2.13.2
|
2024-09-28 11:38:45 +03:00
|
|
|
HARFBUZZ_VERSION=10.0.1
|
2024-09-13 03:52:36 +03:00
|
|
|
LIBPNG_VERSION=1.6.44
|
2024-09-15 14:57:45 +03:00
|
|
|
JPEGTURBO_VERSION=3.0.4
|
2024-02-27 23:05:47 +03:00
|
|
|
OPENJPEG_VERSION=2.5.2
|
2024-10-02 02:48:09 +03:00
|
|
|
XZ_VERSION=5.6.3
|
2023-10-09 13:49:00 +03:00
|
|
|
TIFF_VERSION=4.6.0
|
2023-12-04 00:32:39 +03:00
|
|
|
LCMS2_VERSION=2.16
|
2022-01-25 01:54:24 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]]; then
|
2024-02-19 15:29:58 +03:00
|
|
|
GIFLIB_VERSION=5.2.2
|
2022-01-25 01:54:24 +03:00
|
|
|
else
|
|
|
|
GIFLIB_VERSION=5.2.1
|
2022-04-03 05:12:40 +03:00
|
|
|
fi
|
2022-05-31 03:12:20 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]] || [[ "$MB_ML_VER" != 2014 ]]; then
|
2024-01-23 00:52:14 +03:00
|
|
|
ZLIB_VERSION=1.3.1
|
2022-04-03 05:12:40 +03:00
|
|
|
else
|
2022-02-16 06:25:20 +03:00
|
|
|
ZLIB_VERSION=1.2.8
|
2022-01-25 01:54:24 +03:00
|
|
|
fi
|
2024-04-13 06:47:52 +03:00
|
|
|
LIBWEBP_VERSION=1.4.0
|
2019-12-07 16:02:47 +03:00
|
|
|
BZIP2_VERSION=1.0.8
|
2024-04-16 00:14:04 +03:00
|
|
|
LIBXCB_VERSION=1.17.0
|
2023-08-31 14:05:36 +03:00
|
|
|
BROTLI_VERSION=1.1.0
|
2016-07-31 23:09:20 +03:00
|
|
|
|
2022-09-09 01:05:44 +03:00
|
|
|
function build_brotli {
|
|
|
|
local cmake=$(get_modern_cmake)
|
2024-09-09 05:56:28 +03:00
|
|
|
local out_dir=$(fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz brotli-$BROTLI_VERSION.tar.gz)
|
2022-09-09 01:05:44 +03:00
|
|
|
(cd $out_dir \
|
|
|
|
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
|
|
|
|
&& make install)
|
2023-09-07 17:00:37 +03:00
|
|
|
if [[ "$MB_ML_LIBC" == "manylinux" ]]; then
|
2022-09-09 05:16:23 +03:00
|
|
|
cp /usr/local/lib64/libbrotli* /usr/local/lib
|
|
|
|
cp /usr/local/lib64/pkgconfig/libbrotli* /usr/local/lib/pkgconfig
|
|
|
|
fi
|
2022-09-09 01:05:44 +03:00
|
|
|
}
|
|
|
|
|
2024-09-09 05:56:28 +03:00
|
|
|
function build_harfbuzz {
|
2024-09-28 11:38:45 +03:00
|
|
|
python3 -m pip install meson ninja
|
|
|
|
|
|
|
|
local out_dir=$(fetch_unpack https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION/$HARFBUZZ_VERSION.tar.xz harfbuzz-$HARFBUZZ_VERSION.tar.xz)
|
|
|
|
(cd $out_dir \
|
|
|
|
&& meson setup build --buildtype=release -Dfreetype=enabled -Dglib=disabled)
|
|
|
|
(cd $out_dir/build \
|
|
|
|
&& meson install)
|
|
|
|
if [[ "$MB_ML_LIBC" == "manylinux" ]]; then
|
|
|
|
cp /usr/local/lib64/libharfbuzz* /usr/local/lib
|
2024-09-09 05:56:28 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-11-14 15:23:46 +03:00
|
|
|
function build {
|
2023-11-17 10:39:37 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]] && [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
2024-03-02 15:36:19 +03:00
|
|
|
sudo chown -R runner /usr/local
|
2023-11-17 10:39:37 +03:00
|
|
|
fi
|
2021-07-12 15:25:23 +03:00
|
|
|
build_xz
|
2022-03-30 03:36:47 +03:00
|
|
|
if [ -z "$IS_ALPINE" ] && [ -z "$IS_MACOS" ]; then
|
2021-09-23 14:42:30 +03:00
|
|
|
yum remove -y zlib-devel
|
|
|
|
fi
|
2021-06-16 14:27:59 +03:00
|
|
|
build_new_zlib
|
2020-06-09 14:09:57 +03:00
|
|
|
|
2024-04-16 00:13:40 +03:00
|
|
|
build_simple xcb-proto 1.17.0 https://xorg.freedesktop.org/archive/individual/proto
|
2021-05-16 01:18:02 +03:00
|
|
|
if [ -n "$IS_MACOS" ]; then
|
2024-03-26 12:17:06 +03:00
|
|
|
build_simple xorgproto 2024.1 https://www.x.org/pub/individual/proto
|
2024-01-30 14:57:17 +03:00
|
|
|
build_simple libXau 1.0.11 https://www.x.org/pub/individual/lib
|
|
|
|
build_simple libpthread-stubs 0.5 https://xcb.freedesktop.org/dist
|
2024-03-02 15:36:19 +03:00
|
|
|
if [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
|
|
|
cp /usr/local/share/pkgconfig/xcb-proto.pc /usr/local/lib/pkgconfig
|
2023-11-16 00:13:08 +03:00
|
|
|
fi
|
2021-05-16 01:18:02 +03:00
|
|
|
else
|
2022-09-17 16:37:23 +03:00
|
|
|
sed s/\${pc_sysrootdir\}// /usr/local/share/pkgconfig/xcb-proto.pc > /usr/local/lib/pkgconfig/xcb-proto.pc
|
2021-05-16 01:18:02 +03:00
|
|
|
fi
|
2023-09-01 01:41:55 +03:00
|
|
|
build_simple libxcb $LIBXCB_VERSION https://www.x.org/releases/individual/lib
|
2021-05-16 04:58:25 +03:00
|
|
|
|
2021-12-31 07:53:19 +03:00
|
|
|
build_libjpeg_turbo
|
2016-07-31 23:09:20 +03:00
|
|
|
build_tiff
|
|
|
|
build_libpng
|
|
|
|
build_lcms2
|
2021-02-09 04:23:09 +03:00
|
|
|
build_openjpeg
|
2024-02-27 23:05:47 +03:00
|
|
|
if [ -f /usr/local/lib64/libopenjp2.so ]; then
|
|
|
|
cp /usr/local/lib64/libopenjp2.so /usr/local/lib
|
|
|
|
fi
|
2018-10-13 13:54:45 +03:00
|
|
|
|
2022-04-09 02:46:13 +03:00
|
|
|
ORIGINAL_CFLAGS=$CFLAGS
|
2019-09-02 15:13:42 +03:00
|
|
|
CFLAGS="$CFLAGS -O3 -DNDEBUG"
|
2023-07-08 09:25:44 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]]; then
|
|
|
|
CFLAGS="$CFLAGS -Wl,-headerpad_max_install_names"
|
|
|
|
fi
|
2016-07-31 23:09:20 +03:00
|
|
|
build_libwebp
|
2019-09-02 15:13:42 +03:00
|
|
|
CFLAGS=$ORIGINAL_CFLAGS
|
2018-10-13 13:54:45 +03:00
|
|
|
|
2022-09-09 01:05:44 +03:00
|
|
|
build_brotli
|
|
|
|
|
2021-01-10 14:19:26 +03:00
|
|
|
if [ -n "$IS_MACOS" ]; then
|
2020-01-25 16:50:56 +03:00
|
|
|
# Custom freetype build
|
2022-09-09 01:05:44 +03:00
|
|
|
build_simple freetype $FREETYPE_VERSION https://download.savannah.gnu.org/releases/freetype tar.gz --with-harfbuzz=no
|
2016-06-20 21:30:30 +03:00
|
|
|
else
|
2020-01-25 16:50:56 +03:00
|
|
|
build_freetype
|
2016-06-20 21:30:30 +03:00
|
|
|
fi
|
2020-12-29 02:39:51 +03:00
|
|
|
|
2024-09-09 05:56:28 +03:00
|
|
|
build_harfbuzz
|
2016-06-20 21:30:30 +03:00
|
|
|
}
|
|
|
|
|
2023-11-14 15:23:46 +03:00
|
|
|
# Any stuff that you need to do before you start building the wheels
|
|
|
|
# Runs in the root directory of this repository.
|
|
|
|
curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
|
|
|
|
untar pillow-depends-main.zip
|
2021-01-02 17:12:41 +03:00
|
|
|
|
2023-11-14 15:23:46 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]]; then
|
2024-03-02 15:36:19 +03:00
|
|
|
# libtiff and libxcb cause a conflict with building libtiff and libxcb
|
2024-01-30 14:22:13 +03:00
|
|
|
# libxau and libxdmcp cause an issue on macOS < 11
|
2023-11-14 15:23:46 +03:00
|
|
|
# remove cairo to fix building harfbuzz on arm64
|
|
|
|
# remove lcms2 and libpng to fix building openjpeg on arm64
|
2024-03-03 23:43:40 +03:00
|
|
|
# remove jpeg-turbo to avoid inclusion on arm64
|
|
|
|
# remove webp and zstd to avoid inclusion on x86_64
|
2023-11-17 22:43:40 +03:00
|
|
|
# curl from brew requires zstd, use system curl
|
2024-03-02 15:36:19 +03:00
|
|
|
brew remove --ignore-dependencies libpng libtiff libxcb libxau libxdmcp curl cairo lcms2 zstd
|
2024-03-03 23:43:40 +03:00
|
|
|
if [[ "$CIBW_ARCHS" == "arm64" ]]; then
|
|
|
|
brew remove --ignore-dependencies jpeg-turbo
|
|
|
|
else
|
|
|
|
brew remove --ignore-dependencies webp
|
|
|
|
fi
|
2023-11-14 15:23:46 +03:00
|
|
|
|
2024-09-28 11:38:45 +03:00
|
|
|
brew install pkg-config
|
2023-11-14 15:23:46 +03:00
|
|
|
fi
|
2016-06-20 21:30:30 +03:00
|
|
|
|
2023-11-14 15:23:46 +03:00
|
|
|
wrap_wheel_builder build
|
2016-07-31 23:09:20 +03:00
|
|
|
|
2023-11-14 15:23:46 +03:00
|
|
|
# Append licenses
|
|
|
|
for filename in wheels/dependency_licenses/*; do
|
|
|
|
echo -e "\n\n----\n\n$(basename $filename | cut -f 1 -d '.')\n" | cat >> LICENSE
|
|
|
|
cat $filename >> LICENSE
|
|
|
|
done
|