Skip to content

Commit

Permalink
ci(win): bundle rav1e, libyuv, libsharpyuv in wheels, add python 3.12 (
Browse files Browse the repository at this point in the history
…#30)

* ci: Update winbuild, bundle rav1e, libyuv, libsharpyuv in windows wheels

* ci: Build windows wheel for python 3.12

* Update libavif sha
  • Loading branch information
fdintino authored Oct 6, 2023
1 parent fb9712d commit f046fa2
Show file tree
Hide file tree
Showing 4 changed files with 378 additions and 308 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
MACOSX_DEPLOYMENT_TARGET: "10.10"
WHEEL_SDIR: wheelhouse
CONFIG_PATH: pillow-avif-plugin/wheelbuild/config.sh
LIBAVIF_VERSION: 0.10.1
LIBAVIF_VERSION: ee29bec775ab8e6d555f602775301c14302b96e7

jobs:
build:
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
architecture: ["x64"]
include:
- architecture: "x64"
Expand Down Expand Up @@ -202,12 +202,12 @@ jobs:
- name: Install dependencies
id: install
run: |
7z x winbuild\depends\nasm-2.14.02-win64.zip "-o$env:RUNNER_WORKSPACE\"
echo "$env:RUNNER_WORKSPACE\nasm-2.14.02" >> $env:GITHUB_PATH
7z x winbuild\depends\nasm-2.16.01-win64.zip "-o$env:RUNNER_WORKSPACE\"
echo "$env:RUNNER_WORKSPACE\nasm-2.16.01" >> $env:GITHUB_PATH
winbuild\depends\gs9533w32.exe /S
echo "C:\Program Files (x86)\gs\gs9.53.3\bin" >> $env:GITHUB_PATH
python -m pip install meson
# make cache key depend on VS version
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" `
| find """catalog_buildVersion""" `
| ForEach-Object { $a = $_.split(" ")[1]; echo "vs=$a" >> $env:GITHUB_OUTPUT }
Expand All @@ -224,7 +224,7 @@ jobs:
- name: Prepare build
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
& python.exe winbuild\build_prepare.py -v --python=$env:pythonLocation --srcdir
& python.exe winbuild\build_prepare.py -v
shell: pwsh

- name: Build dependencies / libjpeg-turbo
Expand All @@ -248,21 +248,28 @@ jobs:
run: python -m pip install meson
shell: cmd

- name: Build dependencies / rav1e
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\build_dep_rav1e.cmd"

- name: Build dependencies / libavif
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\build_dep_libavif.cmd"

- name: Install dependencies / Pillow
run: "& winbuild\\build\\install_pillow.cmd"

# trim ~150MB x 9
- name: Optimize build cache
if: steps.build-cache.outputs.cache-hit != 'true'
run: rmdir /S /Q winbuild\build\src
shell: cmd

- name: Install dependencies / Pillow
run: |
cmd /c "winbuild\build\build_env.cmd && $env:pythonLocation\python.exe -m pip install -v Pillow"
shell: pwsh

- name: Build pillow-avif-plugin
run: "& winbuild\\build\\build_pillow_avif_plugin.cmd install"
run: |
cmd /c "winbuild\build\build_env.cmd && $env:pythonLocation\python.exe -m pip install -v ."
shell: pwsh

# failing with PyPy3
Expand Down Expand Up @@ -305,15 +312,14 @@ jobs:
id: wheel
if: "github.event_name == 'push'"
run: |
for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo dist=dist-%%a >> %GITHUB_OUTPUT%
winbuild\\build\\build_pillow_avif_plugin.cmd bdist_wheel
shell: cmd
cmd /c "winbuild\build\build_env.cmd && $env:pythonLocation\python.exe -m pip wheel -v ."
shell: pwsh

- uses: actions/upload-artifact@v3
if: "github.event_name == 'push'"
with:
name: wheels
path: dist\*.whl
path: "*.whl"

success:
needs: [build, windows]
Expand Down
7 changes: 6 additions & 1 deletion depends/install_libavif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ PKGCONFIG=${PKGCONFIG:-pkg-config}
export CFLAGS="-fPIC -O3 $CFLAGS"
export CXXFLAGS="-fPIC -O3 $CXXFLAGS"

ARCHIVE="${LIBAVIF_VERSION}.tar.gz"
if [[ "$LIBAVIF_VERSION" == *"."* ]]; then
ARCHIVE="v${ARCHIVE}"
fi

echo "::group::Fetching libavif"
mkdir -p libavif-$LIBAVIF_VERSION
curl -sLo - \
https://github.com/AOMediaCodec/libavif/archive/v$LIBAVIF_VERSION.tar.gz \
https://github.com/AOMediaCodec/libavif/archive/$ARCHIVE \
| tar --strip-components=1 -C libavif-$LIBAVIF_VERSION -zxf -
pushd libavif-$LIBAVIF_VERSION
echo "::endgroup::"
Expand Down
24 changes: 14 additions & 10 deletions wheelbuild/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ set -eo pipefail
CONFIG_DIR=$(abspath $(dirname "${BASH_SOURCE[0]}"))

ARCHIVE_SDIR=pillow-avif-plugin-depends
LIBAVIF_VERSION=1.0.1
LIBAVIF_VERSION=ee29bec775ab8e6d555f602775301c14302b96e7
AOM_VERSION=3.7.0
DAV1D_VERSION=1.2.1
SVT_AV1_VERSION=1.7.0
RAV1E_VERSION=p20230911
RAV1E_VERSION=p20231003
LIBWEBP_SHA=e2c85878f6a33f29948b43d3492d9cdaf801aa54
LIBYUV_SHA=464c51a0
CCACHE_VERSION=4.7.1
Expand All @@ -23,6 +23,11 @@ alias trace_off='{ set +x; } 2>/dev/null'
alias trace_suppress='{ [[ $- =~ .*x.* ]] && trace_enabled=1 || trace_enabled=0; set +x; } 2>/dev/null'
alias trace_restore='{ [ $trace_enabled -eq 1 ] && trace_on || trace_off; } 2>/dev/null'

if [ -n "$IS_MACOS" ] && [ -n "$MACOSX_DEPLOYMENT_TARGET" ]; then
CFLAGS="${CFLAGS} -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
LDFLAGS="${LDFLAGS} -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
fi

call_and_restore_trace() {
local rc
local force_trace
Expand Down Expand Up @@ -222,6 +227,7 @@ function build_aom {
(cd libaom-$AOM_VERSION/build/work \
&& cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCONFIG_PIC=1 \
-DCMAKE_INSTALL_PREFIX="${BUILD_PREFIX}" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=0 \
Expand Down Expand Up @@ -345,8 +351,8 @@ function build_rav1e {
fi

curl -sLo - \
https://github.com/fdintino/rav1e/releases/download/$RAV1E_VERSION/$librav1e_tgz \
| tar -C $BUILD_PREFIX -zxf -
https://github.com/xiph/rav1e/releases/download/$RAV1E_VERSION/$librav1e_tgz \
| tar -C $BUILD_PREFIX --exclude LICENSE -zxf -

if [ ! -n "$IS_MACOS" ]; then
sed -i 's/-lgcc_s/-lgcc_eh/g' "${BUILD_PREFIX}/lib/pkgconfig/rav1e.pc"
Expand Down Expand Up @@ -467,14 +473,11 @@ function build_libavif {
group_start "Download libavif source"

fetch_unpack \
"https://github.com/AOMediaCodec/libavif/archive/v$LIBAVIF_VERSION.tar.gz" \
"https://github.com/AOMediaCodec/libavif/archive/$LIBAVIF_VERSION.tar.gz" \
"libavif-$LIBAVIF_VERSION.tar.gz"

group_end

(cd libavif-$LIBAVIF_VERSION \
&& patch -p1 -i $CONFIG_DIR/libavif-1.0.1-local-static.patch)

build_libsharpyuv
mv libwebp-$LIBWEBP_SHA libavif-$LIBAVIF_VERSION/ext/libwebp
LIBAVIF_CMAKE_FLAGS+=(-DAVIF_LOCAL_LIBSHARPYUV=ON)
Expand All @@ -489,11 +492,12 @@ function build_libavif {

(cd libavif-$LIBAVIF_VERSION/build \
&& cmake .. \
-G "Ninja" \
-DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DBUILD_SHARED_LIBS=OFF \
"${LIBAVIF_CMAKE_FLAGS[@]}" \
&& make install)
&& ninja -v install/strip)

group_end
}
Expand Down
Loading

0 comments on commit f046fa2

Please sign in to comment.