Skip to content

Commit

Permalink
Cache libimagequant
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jan 21, 2024
1 parent 07e8e33 commit 1822e3b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,21 @@ jobs:
- name: Build system information
run: python3 .github/workflows/system-info.py

- name: Cache libimagequant
if: startsWith(matrix.os, 'ubuntu')
uses: actions/cache@v4
id: cache-libimagequant
with:
path: ~/cache-libimagequant
key: ${{ runner.os }}-libimagequant-${{ hashFiles('depends/install_imagequant.sh') }}

- name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
.ci/install.sh
env:
GHA_PYTHON_VERSION: ${{ matrix.python-version }}
GHA_LIBIMAGEQUANT_CACHE_HIT: ${{ steps.cache-libimagequant.outputs.cache-hit }}

- name: Install macOS dependencies
if: startsWith(matrix.os, 'macOS')
Expand Down
38 changes: 30 additions & 8 deletions depends/install_imagequant.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
#!/bin/bash
# install libimagequant

archive=libimagequant-4.2.2
archive_name=libimagequant
archive_version=4.2.2

./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz
archive=$archive_name-$archive_version

pushd $archive/imagequant-sys
if [[ "$GHA_LIBIMAGEQUANT_CACHE_HIT" == "true" ]]; then

cargo install cargo-c
cargo cinstall --prefix=/usr --destdir=.
sudo cp usr/lib/libimagequant.so* /usr/lib/
sudo cp usr/include/libimagequant.h /usr/include/
# Copy cached files into place
sudo cp ~/cache-$archive_name/libimagequant.so* /usr/lib/
sudo cp ~/cache-$archive_name/libimagequant.h /usr/include/

popd
else

# Build from source
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz

pushd $archive/imagequant-sys

time cargo install cargo-c
time cargo cinstall --prefix=/usr --destdir=.

# Copy into place
sudo cp usr/lib/libimagequant.so* /usr/lib/
sudo cp usr/include/libimagequant.h /usr/include/

# Copy to cache
rm -rf ~/cache-$archive_name
mkdir ~/cache-$archive_name
cp usr/lib/libimagequant.so* ~/cache-$archive_name/
cp usr/include/libimagequant.h ~/cache-$archive_name/

popd

fi

0 comments on commit 1822e3b

Please sign in to comment.