Correct handling of vendored fribidi.

This commit is contained in:
Russell Keith-Magee 2024-11-06 14:12:07 +08:00
parent 51e3623066
commit e82b5398e7
No known key found for this signature in database
GPG Key ID: 3D2DAB6A37BB5BC3
4 changed files with 43 additions and 19 deletions

View File

@ -1,16 +1,34 @@
#!/bin/bash
# Setup that needs to be done before multibuild utils are invoked
PROJECTDIR=$(pwd)
if [[ "$(uname -s)" == "Darwin" ]]; then
# Build and install macOS builds into the `build/deps` folder.
BUILD_PREFIX=$(pwd)/build/deps
# Safety check - macOS builds require that CIBW_ARCHS is set, and that it
# only contains a single value (even though cwbuildwheel) allows multiple
# values in CIBW_ARCHS.
if [[ -z "$CIBW_ARCHS" ]]; then
echo "ERROR: Pillow macOS builds require CIBW_ARCHS be defined."
exit 1
fi
if [[ "$CIBW_ARCHS" == *" "* ]]; then
echo "ERROR: Pillow macOS builds only support a single architecture in CIBW_ARCHS."
exit 1
fi
# Build macOS dependencies in `build/darwin`
# Install them into `build/deps/darwin`
WORKDIR=$(pwd)/build/darwin
BUILD_PREFIX=$(pwd)/build/deps/darwin
PLAT=$CIBW_ARCHS
else
export MB_ML_LIBC=${AUDITWHEEL_POLICY::9}
export MB_ML_VER=${AUDITWHEEL_POLICY:9}
# Build prefix will default to /usr/local
WORKDIR=$(pwd)/build
PLAT=$CIBW_ARCHS
MB_ML_LIBC=${AUDITWHEEL_POLICY::9}
MB_ML_VER=${AUDITWHEEL_POLICY:9}
fi
# Define custom utilities
export PLAT=$CIBW_ARCHS
source wheels/multibuild/common_utils.sh
source wheels/multibuild/library_builders.sh
if [ -z "$IS_MACOS" ]; then
@ -117,9 +135,6 @@ function build {
ORIGINAL_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -O3 -DNDEBUG"
if [[ -n "$IS_MACOS" ]]; then
CFLAGS="$CFLAGS -Wl,-headerpad_max_install_names"
fi
build_libwebp
CFLAGS=$ORIGINAL_CFLAGS
@ -127,7 +142,7 @@ function build {
if [ -n "$IS_MACOS" ]; then
# Custom freetype build
build_simple freetype $FREETYPE_VERSION https://download.savannah.gnu.org/releases/freetype tar.gz --with-harfbuzz=no
build_simple freetype $FREETYPE_VERSION https://download.savannah.gnu.org/releases/freetype tar.gz --without-harfbuzz
else
build_freetype
fi
@ -136,17 +151,18 @@ function build {
}
# Perform all dependency builds in the build subfolder.
mkdir -p build
pushd build > /dev/null
mkdir -p $WORKDIR
pushd $WORKDIR > /dev/null
# Any stuff that you need to do before you start building the wheels
# Runs in the root directory of this repository.
if [[ ! -d pillow-depends-main ]]; then
if [[ ! -f pillow-depends-main.zip ]]; then
if [[ ! -d $WORKDIR/pillow-depends-main ]]; then
if [[ ! -f $PROJECTDIR/pillow-depends-main.zip ]]; then
echo "Download pillow dependency sources..."
curl -fSL -o pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
curl -fSL -o $PROJECTDIR/pillow-depends-main.zip https://github.com/python-pillow/pillow-depends/archive/main.zip
fi
untar pillow-depends-main.zip
echo "Unpacking pillow dependency sources..."
untar $PROJECTDIR/pillow-depends-main.zip
fi
if [[ -n "$IS_MACOS" ]]; then

View File

@ -16,8 +16,12 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
fi
$HOMEBREW_HOME/bin/brew install fribidi
# Add the Homebrew lib folder so that vendored libraries can be found.
export DYLD_LIBRARY_PATH=$HOMEBREW_HOME/lib
# Add the lib folder for fribidi so that the vendored library can be found.
# Don't use /opt/homebrew/lib directly - use the lib folder where the
# installed copy of fribidi is cellared. This ensures we don't pick up the
# Homebrew version of any other library that we're dependent on (most notably,
# freetype).
export DYLD_LIBRARY_PATH=$(dirname $(realpath $HOMEBREW_HOME/lib/libfribidi.dylib))
elif [ "${AUDITWHEEL_POLICY::9}" == "musllinux" ]; then
apk add curl fribidi
else

4
.gitignore vendored
View File

@ -91,5 +91,9 @@ Tests/images/msp
Tests/images/picins
Tests/images/sunraster
# Test and dependency downloads
pillow-depends-main.zip
pillow-test-images.zip
# pyinstaller
*.spec

View File

@ -96,13 +96,13 @@ build-verbosity = 1
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
# Add an explicit dependencies prefix for macOS.
macos.config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable dependencies-prefix=./build/deps"
macos.config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable dependencies-prefix=./build/deps/darwin"
test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-extras = "tests"
[tool.cibuildwheel.macos.environment]
PATH = "$(pwd)/build/deps/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
PATH = "$(pwd)/build/deps/darwin/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
[tool.black]
exclude = "wheels/multibuild"