2016-06-20 21:30:30 +03:00
|
|
|
# Define custom utilities
|
2020-04-25 14:51:55 +03:00
|
|
|
# Test for OS X with [ -n "$IS_OSX" ]
|
2016-06-20 21:30:30 +03:00
|
|
|
|
2018-07-03 12:41:06 +03:00
|
|
|
ARCHIVE_SDIR=pillow-depends-master
|
|
|
|
|
2016-07-31 23:09:20 +03:00
|
|
|
# Package versions for fresh source builds
|
2020-10-20 11:56:34 +03:00
|
|
|
FREETYPE_VERSION=2.10.4
|
2021-01-02 15:29:37 +03:00
|
|
|
HARFBUZZ_VERSION=2.7.4
|
2019-04-16 13:00:11 +03:00
|
|
|
LIBPNG_VERSION=1.6.37
|
2017-01-17 12:41:21 +03:00
|
|
|
ZLIB_VERSION=1.2.11
|
2020-01-12 14:40:06 +03:00
|
|
|
JPEG_VERSION=9d
|
2020-12-29 02:42:21 +03:00
|
|
|
OPENJPEG_VERSION=2.4.0
|
2020-03-18 10:05:25 +03:00
|
|
|
XZ_VERSION=5.2.5
|
2020-12-20 05:02:29 +03:00
|
|
|
TIFF_VERSION=4.2.0
|
2020-06-17 00:47:16 +03:00
|
|
|
LCMS2_VERSION=2.11
|
2018-09-16 05:12:25 +03:00
|
|
|
GIFLIB_VERSION=5.1.4
|
2020-01-07 11:18:56 +03:00
|
|
|
LIBWEBP_VERSION=1.1.0
|
2019-12-07 16:02:47 +03:00
|
|
|
BZIP2_VERSION=1.0.8
|
2020-06-07 13:31:05 +03:00
|
|
|
LIBXCB_VERSION=1.14
|
2016-07-31 23:09:20 +03:00
|
|
|
|
2021-01-02 15:29:37 +03:00
|
|
|
# workaround for multibuild bug with .tar.xz
|
|
|
|
function untar {
|
|
|
|
local in_fname=$1
|
|
|
|
if [ -z "$in_fname" ];then echo "in_fname not defined"; exit 1; fi
|
|
|
|
local extension=${in_fname##*.}
|
|
|
|
case $extension in
|
|
|
|
tar) tar -xf $in_fname ;;
|
|
|
|
gz|tgz) tar -zxf $in_fname ;;
|
|
|
|
bz2) tar -jxf $in_fname ;;
|
|
|
|
zip) unzip -qq $in_fname ;;
|
|
|
|
xz) unxz -c $in_fname | tar -xf - ;;
|
|
|
|
*) echo Did not recognize extension $extension; exit 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
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.
|
2018-07-03 12:41:06 +03:00
|
|
|
curl -fsSL -o pillow-depends-master.zip https://github.com/python-pillow/pillow-depends/archive/master.zip
|
|
|
|
untar pillow-depends-master.zip
|
2016-06-20 21:30:30 +03:00
|
|
|
if [ -n "$IS_OSX" ]; then
|
2020-04-25 14:51:55 +03:00
|
|
|
# Update to latest zlib for OS X build
|
2016-07-31 23:09:20 +03:00
|
|
|
build_new_zlib
|
2020-06-09 14:09:57 +03:00
|
|
|
fi
|
|
|
|
|
2020-06-28 07:57:13 +03:00
|
|
|
if [ -n "$IS_OSX" ]; then
|
|
|
|
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
|
2020-10-09 14:49:41 +03:00
|
|
|
build_simple xcb-proto 1.14.1 https://xcb.freedesktop.org/dist
|
2020-06-09 14:09:57 +03:00
|
|
|
if [ -n "$IS_OSX" ]; then
|
2020-06-07 13:31:05 +03:00
|
|
|
build_simple xproto 7.0.31 https://www.x.org/pub/individual/proto
|
|
|
|
build_simple libXau 1.0.9 https://www.x.org/pub/individual/lib
|
|
|
|
build_simple libpthread-stubs 0.4 https://xcb.freedesktop.org/dist
|
2020-06-09 14:09:57 +03:00
|
|
|
else
|
|
|
|
sed -i s/\${pc_sysrootdir\}// /usr/local/lib/pkgconfig/xcb-proto.pc
|
2016-07-31 23:09:20 +03:00
|
|
|
fi
|
2020-06-09 14:09:57 +03:00
|
|
|
build_simple libxcb $LIBXCB_VERSION https://xcb.freedesktop.org/dist
|
2020-06-28 07:57:13 +03:00
|
|
|
if [ -n "$IS_OSX" ]; then
|
|
|
|
BUILD_PREFIX=$ORIGINAL_BUILD_PREFIX
|
|
|
|
PKG_CONFIG_PATH=$ORIGINAL_PKG_CONFIG_PATH
|
|
|
|
fi
|
2019-04-08 12:07:51 +03:00
|
|
|
|
|
|
|
# Custom flags to include both multibuild and jpeg defaults
|
|
|
|
ORIGINAL_CFLAGS=$CFLAGS
|
|
|
|
CFLAGS="$CFLAGS -g -O2"
|
2016-07-31 23:09:20 +03:00
|
|
|
build_jpeg
|
2019-04-08 12:07:51 +03:00
|
|
|
CFLAGS=$ORIGINAL_CFLAGS
|
2020-10-23 17:16:09 +03:00
|
|
|
|
2016-07-31 23:09:20 +03:00
|
|
|
build_tiff
|
|
|
|
build_libpng
|
|
|
|
build_lcms2
|
2020-10-03 12:31:36 +03:00
|
|
|
build_openjpeg
|
2018-10-13 13:54:45 +03:00
|
|
|
|
2019-09-02 15:13:42 +03:00
|
|
|
CFLAGS="$CFLAGS -O3 -DNDEBUG"
|
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
|
|
|
|
2016-07-31 23:09:20 +03:00
|
|
|
if [ -n "$IS_OSX" ]; then
|
2020-01-25 16:50:56 +03:00
|
|
|
# Custom freetype build
|
2020-10-23 17:16:09 +03:00
|
|
|
build_simple freetype $FREETYPE_VERSION https://download.savannah.gnu.org/releases/freetype tar.gz --with-harfbuzz=no --with-brotli=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-01-02 18:34:21 +03:00
|
|
|
if [ -z "$IS_OSX" ]; then
|
|
|
|
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-01-02 18:34:21 +03:00
|
|
|
if [ -z "$IS_OSX" ]; then
|
|
|
|
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-01-02 18:56:48 +03:00
|
|
|
if [ -z "$IS_OSX" ]; then
|
|
|
|
CFLAGS="$CFLAGS --std=c99" # for Raqm
|
|
|
|
fi
|
2021-01-02 17:12:41 +03:00
|
|
|
pip wheel $(pip_opts) \
|
|
|
|
--global-option build_ext --global-option --enable-raqm \
|
|
|
|
--global-option --vendor-raqm --global-option --vendor-fribidi \
|
|
|
|
-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
|
|
|
}
|
|
|
|
|
2016-07-31 23:09:20 +03:00
|
|
|
EXP_CODECS="jpg jpg_2000 libtiff zlib"
|
|
|
|
EXP_MODULES="freetype2 littlecms2 pil tkinter webp"
|
2020-06-09 14:09:57 +03:00
|
|
|
EXP_FEATURES="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 {
|
2020-06-28 07:57:57 +03:00
|
|
|
if [ -n "$IS_OSX" ]; then
|
|
|
|
brew install openblas
|
|
|
|
echo -e "[openblas]\nlibraries = openblas\nlibrary_dirs = /usr/local/opt/openblas/lib" >> ~/.numpy-site.cfg
|
|
|
|
fi
|
2020-12-18 08:38:23 +03:00
|
|
|
python3 -m pip install numpy
|
2020-06-28 07:57:57 +03:00
|
|
|
|
2020-09-23 12:57:08 +03:00
|
|
|
mv ../pillow-depends-master/test_images/* ../Pillow/Tests/images
|
|
|
|
|
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
|
|
|
}
|