Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Update config for FriBiDi dynamic linking #181

Merged
merged 10 commits into from
Mar 31, 2021
44 changes: 43 additions & 1 deletion config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARCHIVE_SDIR=pillow-depends-master

# Package versions for fresh source builds
FREETYPE_VERSION=2.10.4
HARFBUZZ_VERSION=2.7.4
nulano marked this conversation as resolved.
Show resolved Hide resolved
LIBPNG_VERSION=1.6.37
ZLIB_VERSION=1.2.11
JPEG_VERSION=9d
Expand All @@ -17,6 +18,21 @@ LIBWEBP_VERSION=1.1.0
BZIP2_VERSION=1.0.8
LIBXCB_VERSION=1.14

# 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 - ;;
Copy link
Contributor Author

@nulano nulano Jan 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is wrong in the multibuild version causing an error in tar; https://github.com/matthew-brett/multibuild/pull/380.

*) echo Did not recognize extension $extension; exit 1 ;;
esac
}

function pre_build {
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
Expand Down Expand Up @@ -69,13 +85,34 @@ function pre_build {
build_freetype
fi

if [ -z "$IS_OSX" ]; then
export FREETYPE_LIBS=-lfreetype
export FREETYPE_CFLAGS=-I/usr/local/include/freetype2/
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HarfBuzz fails to find FreeType on linux without this, specify the path manually.

build_simple harfbuzz $HARFBUZZ_VERSION https://github.com/harfbuzz/harfbuzz/releases/download/$HARFBUZZ_VERSION tar.xz --with-freetype=yes --with-glib=no
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--with-glib=no to avoid pulling in unrelated libraries on macos.

if [ -z "$IS_OSX" ]; then
export FREETYPE_LIBS=''
export FREETYPE_CFLAGS=''
fi

# 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
}

function pip_wheel_cmd {
local abs_wheelhouse=$1
if [ -z "$IS_OSX" ]; then
CFLAGS="$CFLAGS --std=c99" # for Raqm
Copy link
Contributor Author

@nulano nulano Jan 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to compile with C99 than to merge in the (poorly tested) C89 patch from python-pillow/Pillow@b3cfe73, especially when this file is not compiled by default.

fi
pip wheel $(pip_opts) \
--global-option build_ext --global-option --enable-raqm \
--global-option --vendor-raqm --global-option --vendor-fribidi \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overriding pip_wheel_cmd to add the needed global options, as defined in python-pillow/Pillow#5062.

-w $abs_wheelhouse --no-deps .
}

function run_tests_in_repo {
# Run Pillow tests from within source repo
python3 selftest.py
Expand All @@ -84,7 +121,12 @@ function run_tests_in_repo {

EXP_CODECS="jpg jpg_2000 libtiff zlib"
EXP_MODULES="freetype2 littlecms2 pil tkinter webp"
EXP_FEATURES="transp_webp webp_anim webp_mux xcb"
if [ -z "$IS_OSX" ] && [[ "$MB_PYTHON_VERSION" != pypy3* ]]; then
EXP_FEATURES="fribidi harfbuzz raqm transp_webp webp_anim webp_mux xcb"
else
# can't find FriBiDi
EXP_FEATURES="transp_webp webp_anim webp_mux xcb"
Copy link
Contributor Author

@nulano nulano Jan 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS and PyPy on Ubuntu don't find FriBiDi preinstalled. Adding brew install fribidi only finds it on Python 3.6. I'm not sure why this is, but it should be irrelevant given the build_ext flags defined above.

fi

function run_tests {
if [ -n "$IS_OSX" ]; then
Expand Down