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" ]
|
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
|
2023-08-03 01:57:11 +03:00
|
|
|
HARFBUZZ_VERSION=8.1.1
|
2023-06-22 07:07:22 +03:00
|
|
|
LIBPNG_VERSION=1.6.40
|
2023-07-04 01:26:50 +03:00
|
|
|
JPEGTURBO_VERSION=3.0.0
|
2022-05-14 13:54:49 +03:00
|
|
|
OPENJPEG_VERSION=2.5.0
|
2023-08-03 02:03:14 +03:00
|
|
|
XZ_VERSION=5.4.4
|
2023-06-27 01:19:57 +03:00
|
|
|
TIFF_VERSION=4.5.1
|
2023-03-01 03:03:23 +03:00
|
|
|
LCMS2_VERSION=2.15
|
2022-01-25 01:54:24 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]]; then
|
|
|
|
GIFLIB_VERSION=5.1.4
|
|
|
|
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
|
2022-10-13 12:29:09 +03:00
|
|
|
ZLIB_VERSION=1.2.13
|
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
|
2023-06-29 08:11:55 +03:00
|
|
|
LIBWEBP_VERSION=1.3.1
|
2019-12-07 16:02:47 +03:00
|
|
|
BZIP2_VERSION=1.0.8
|
2022-09-16 15:04:14 +03:00
|
|
|
LIBXCB_VERSION=1.15
|
2023-08-31 14:05:36 +03:00
|
|
|
BROTLI_VERSION=1.1.0
|
2016-07-31 23:09:20 +03:00
|
|
|
|
2022-05-14 13:54:49 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]] && [[ "$PLAT" == "x86_64" ]]; then
|
|
|
|
function build_openjpeg {
|
|
|
|
local out_dir=$(fetch_unpack https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz)
|
|
|
|
(cd $out_dir \
|
|
|
|
&& cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
|
|
|
|
&& make install)
|
|
|
|
touch openjpeg-stamp
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2022-09-09 01:05:44 +03:00
|
|
|
function build_brotli {
|
|
|
|
local cmake=$(get_modern_cmake)
|
|
|
|
local out_dir=$(fetch_unpack https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz)
|
|
|
|
(cd $out_dir \
|
|
|
|
&& $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib . \
|
|
|
|
&& make install)
|
2022-09-09 05:16:23 +03:00
|
|
|
if [[ "$MB_ML_LIBC" == "manylinux" ]] && [[ "$PLAT" == "x86_64" ]]; then
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-06-20 21:30:30 +03:00
|
|
|
function pre_build {
|
|
|
|
# Any stuff that you need to do before you start building the wheels
|
|
|
|
# Runs in the root directory of this repository.
|
2021-10-15 16:02:27 +03:00
|
|
|
curl -fsSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
|
|
|
|
untar pillow-depends-main.zip
|
2021-06-16 14:27:59 +03:00
|
|
|
|
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
|
|
|
|
2021-01-10 14:19:26 +03:00
|
|
|
if [ -n "$IS_MACOS" ]; then
|
2020-06-28 07:57:13 +03:00
|
|
|
ORIGINAL_BUILD_PREFIX=$BUILD_PREFIX
|
|
|
|
ORIGINAL_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
|
|
|
|
BUILD_PREFIX=`dirname $(dirname $(which python))`
|
|
|
|
PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig"
|
|
|
|
fi
|
2022-09-17 16:37:23 +03:00
|
|
|
build_simple xcb-proto 1.15.2 https://xcb.freedesktop.org/dist
|
2021-05-16 01:18:02 +03:00
|
|
|
if [ -n "$IS_MACOS" ]; then
|
2022-09-16 14:33:48 +03:00
|
|
|
build_simple xorgproto 2022.2 https://www.x.org/pub/individual/proto
|
2023-01-12 13:00:12 +03:00
|
|
|
build_simple libXau 1.0.11 https://www.x.org/pub/individual/lib
|
2021-05-16 01:18:02 +03:00
|
|
|
build_simple libpthread-stubs 0.4 https://xcb.freedesktop.org/dist
|
2022-09-17 16:37:23 +03:00
|
|
|
cp venv/share/pkgconfig/xcb-proto.pc venv/lib/pkgconfig/xcb-proto.pc
|
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
|
|
|
|
build_simple libxcb $LIBXCB_VERSION https://xcb.freedesktop.org/dist
|
2021-01-10 14:19:26 +03:00
|
|
|
if [ -n "$IS_MACOS" ]; then
|
2020-06-28 07:57:13 +03:00
|
|
|
BUILD_PREFIX=$ORIGINAL_BUILD_PREFIX
|
|
|
|
PKG_CONFIG_PATH=$ORIGINAL_PKG_CONFIG_PATH
|
|
|
|
fi
|
2021-05-16 04:58:25 +03:00
|
|
|
|
2021-12-31 07:53:19 +03:00
|
|
|
build_libjpeg_turbo
|
2021-12-29 13:09:52 +03:00
|
|
|
if [[ -n "$IS_MACOS" ]]; then
|
2022-03-25 22:21:35 +03:00
|
|
|
rm /usr/local/lib/libjpeg.dylib
|
2021-05-09 07:38:00 +03:00
|
|
|
fi
|
2016-07-31 23:09:20 +03:00
|
|
|
build_tiff
|
|
|
|
build_libpng
|
|
|
|
build_lcms2
|
2021-02-09 04:23:09 +03:00
|
|
|
build_openjpeg
|
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
|
|
|
|
2021-03-25 04:14:51 +03:00
|
|
|
if [ -z "$IS_MACOS" ]; then
|
2021-01-02 18:34:21 +03:00
|
|
|
export FREETYPE_LIBS=-lfreetype
|
|
|
|
export FREETYPE_CFLAGS=-I/usr/local/include/freetype2/
|
|
|
|
fi
|
2021-01-02 15:29:37 +03:00
|
|
|
build_simple harfbuzz $HARFBUZZ_VERSION https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION tar.xz --with-freetype=yes --with-glib=no
|
2021-03-25 04:14:51 +03:00
|
|
|
if [ -z "$IS_MACOS" ]; then
|
2021-01-02 18:34:21 +03:00
|
|
|
export FREETYPE_LIBS=''
|
|
|
|
export FREETYPE_CFLAGS=''
|
|
|
|
fi
|
2021-01-02 15:29:37 +03:00
|
|
|
|
2020-12-29 02:39:51 +03:00
|
|
|
# Append licenses
|
|
|
|
for filename in dependency_licenses/*; do
|
|
|
|
echo -e "\n\n----\n\n$(basename $filename | cut -f 1 -d '.')\n" | cat >> Pillow/LICENSE
|
|
|
|
cat $filename >> Pillow/LICENSE
|
|
|
|
done
|
2016-06-20 21:30:30 +03:00
|
|
|
}
|
|
|
|
|
2021-01-02 17:12:41 +03:00
|
|
|
function pip_wheel_cmd {
|
|
|
|
local abs_wheelhouse=$1
|
2021-03-25 04:14:51 +03:00
|
|
|
if [ -z "$IS_MACOS" ]; then
|
2021-01-02 18:56:48 +03:00
|
|
|
CFLAGS="$CFLAGS --std=c99" # for Raqm
|
|
|
|
fi
|
2021-01-02 17:12:41 +03:00
|
|
|
pip wheel $(pip_opts) \
|
2023-06-24 12:48:30 +03:00
|
|
|
-C raqm=enable -C raqm=vendor -C fribidi=vendor \
|
2021-01-02 17:12:41 +03:00
|
|
|
-w $abs_wheelhouse --no-deps .
|
|
|
|
}
|
|
|
|
|
2016-06-20 21:30:30 +03:00
|
|
|
function run_tests_in_repo {
|
|
|
|
# Run Pillow tests from within source repo
|
2020-12-26 13:40:59 +03:00
|
|
|
python3 selftest.py
|
2017-12-27 17:43:53 +03:00
|
|
|
pytest
|
2016-06-20 21:30:30 +03:00
|
|
|
}
|
|
|
|
|
2022-04-09 03:06:37 +03:00
|
|
|
EXP_CODECS="jpg jpg_2000 libtiff zlib"
|
2022-12-30 04:11:07 +03:00
|
|
|
EXP_MODULES="freetype2 littlecms2 pil tkinter webp"
|
2023-06-24 12:48:30 +03:00
|
|
|
EXP_FEATURES="fribidi harfbuzz libjpeg_turbo raqm transp_webp webp_anim webp_mux xcb"
|
2016-07-31 23:09:20 +03:00
|
|
|
|
2016-06-20 21:30:30 +03:00
|
|
|
function run_tests {
|
2021-01-10 14:19:26 +03:00
|
|
|
if [ -n "$IS_MACOS" ]; then
|
2022-04-04 13:46:36 +03:00
|
|
|
brew install fribidi
|
2022-03-31 03:20:01 +03:00
|
|
|
elif [ -n "$IS_ALPINE" ]; then
|
2023-02-11 10:22:28 +03:00
|
|
|
apk add curl fribidi
|
2022-04-09 15:47:09 +03:00
|
|
|
else
|
2023-02-11 10:22:28 +03:00
|
|
|
apt-get update
|
|
|
|
apt-get install -y curl libfribidi0 unzip
|
2020-06-28 07:57:57 +03:00
|
|
|
fi
|
2023-06-23 16:12:29 +03:00
|
|
|
if [ -z "$IS_ALPINE" ] && [[ "$MB_PYTHON_VERSION" != 3.12 ]]; then
|
2021-01-31 07:57:24 +03:00
|
|
|
python3 -m pip install numpy
|
|
|
|
fi
|
2020-06-28 07:57:57 +03:00
|
|
|
|
2023-02-11 10:22:28 +03:00
|
|
|
curl -fsSL -o pillow-test-images.zip https://github.com/python-pillow/test-images/archive/main.zip
|
|
|
|
untar pillow-test-images.zip
|
|
|
|
mv test-images-main/* ../Pillow/Tests/images
|
2020-09-23 12:57:08 +03:00
|
|
|
|
2016-06-20 21:30:30 +03:00
|
|
|
# Runs tests on installed distribution from an empty directory
|
|
|
|
(cd ../Pillow && run_tests_in_repo)
|
2020-06-08 12:35:35 +03:00
|
|
|
# Test against expected codecs, modules and features
|
2016-07-31 23:09:20 +03:00
|
|
|
local ret=0
|
2020-12-26 13:40:59 +03:00
|
|
|
local codecs=$(python3 -c 'from PIL.features import *; print(" ".join(sorted(get_supported_codecs())))')
|
2016-07-31 23:09:20 +03:00
|
|
|
if [ "$codecs" != "$EXP_CODECS" ]; then
|
|
|
|
echo "Codecs should be: '$EXP_CODECS'; but are '$codecs'"
|
|
|
|
ret=1
|
|
|
|
fi
|
2020-12-26 13:40:59 +03:00
|
|
|
local modules=$(python3 -c 'from PIL.features import *; print(" ".join(sorted(get_supported_modules())))')
|
2016-07-31 23:09:20 +03:00
|
|
|
if [ "$modules" != "$EXP_MODULES" ]; then
|
|
|
|
echo "Modules should be: '$EXP_MODULES'; but are '$modules'"
|
|
|
|
ret=1
|
|
|
|
fi
|
2020-12-26 13:40:59 +03:00
|
|
|
local features=$(python3 -c 'from PIL.features import *; print(" ".join(sorted(get_supported_features())))')
|
2020-06-08 12:35:35 +03:00
|
|
|
if [ "$features" != "$EXP_FEATURES" ]; then
|
|
|
|
echo "Features should be: '$EXP_FEATURES'; but are '$features'"
|
|
|
|
ret=1
|
|
|
|
fi
|
2016-07-31 23:09:20 +03:00
|
|
|
return $ret
|
2016-06-20 21:30:30 +03:00
|
|
|
}
|