Skip to content

Commit bf59acd

Browse files
committed
v0.1.7
1 parent 65f4fd2 commit bf59acd

File tree

7 files changed

+276
-135
lines changed

7 files changed

+276
-135
lines changed

.github/workflows/build-cache-deps.yml

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ jobs:
1313
name: ${{ matrix.cibw_arch }} • ${{ matrix.cibw_buildlinux }}
1414
runs-on: ubuntu-20.04
1515
env:
16-
BUILD_STUFF: "/build-stuff"
17-
SCRIPTS: "./build_scripts/linux/"
18-
BUILD_ORDER: "pkg-config,nasm,libde265,aom,libheif,libffi"
1916
KEY_HEAD: ${{ matrix.cibw_arch }}-${{ matrix.cibw_buildlinux }}
17+
BUILD_DIR_PREFIX: "/tmp/pillow_heif"
2018

2119
steps:
2220
- uses: actions/checkout@v2
@@ -26,79 +24,40 @@ jobs:
2624
with:
2725
platforms: arm64
2826

29-
- name: Preparations
30-
run: |
31-
sudo mkdir "$BUILD_STUFF" && sudo chmod 777 "$BUILD_STUFF"
32-
echo BUILD_STUFF_CMD="&& sh $(echo "$BUILD_ORDER" | sed 's/,/.sh \&\& sh /g').sh" >> $GITHUB_ENV
33-
python3 -m pip install cibuildwheel twine
27+
- name: Install cibuildwheel & twine
28+
run: python3 -m pip install cibuildwheel twine
3429

3530
- name: manylinux preparations
3631
if: matrix.cibw_buildlinux == 'manylinux'
37-
run: |
38-
echo BUILD_COMMAND="yum install -y -q $OS_PACKAGES && set -ex && cd $SCRIPTS $BUILD_STUFF_CMD" >> $GITHUB_ENV
39-
echo LDCONFIG_ARG="" >> $GITHUB_ENV
32+
run: echo INSTALL_OS_PACKAGES="yum update -y && yum install -y $OS_PACKAGES" >> $GITHUB_ENV
4033
env:
41-
OS_PACKAGES: "wget libtool git-all"
34+
OS_PACKAGES: "git-all"
4235

4336
- name: musllinux preparations
4437
if: matrix.cibw_buildlinux == 'musllinux'
45-
run: |
46-
echo BUILD_COMMAND="apk --no-cache add -q $OS_PACKAGES && set -ex && cd $SCRIPTS $BUILD_STUFF_CMD" >> $GITHUB_ENV
47-
echo LDCONFIG_ARG="/usr/lib" >> $GITHUB_ENV
38+
run: echo INSTALL_OS_PACKAGES="apk update && apk --no-cache add $OS_PACKAGES" >> $GITHUB_ENV
4839
env:
49-
OS_PACKAGES: "sudo py3-pip python3-dev libtool git \
50-
freetype-dev fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev openjpeg-dev tiff-dev zlib-dev"
40+
OS_PACKAGES: "sudo py3-pip python3-dev fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev openjpeg-dev"
5141

5242
- uses: actions/cache@v2
5343
with:
54-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
55-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
56-
env:
57-
NAME: pkg-config
58-
59-
- uses: actions/cache@v2
60-
with:
61-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
62-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
63-
env:
64-
NAME: nasm
44+
path: ${{ env.BUILD_DIR_PREFIX }}/build-tools
45+
key: ${{ env.KEY_HEAD }}-${{ hashFiles('libheif/*.py') }}
6546

6647
- uses: actions/cache@v2
6748
with:
68-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
69-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
70-
env:
71-
NAME: libde265
72-
73-
- uses: actions/cache@v2
74-
with:
75-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
76-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
77-
env:
78-
NAME: aom
79-
80-
- uses: actions/cache@v2
81-
with:
82-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
83-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
84-
env:
85-
NAME: libheif
86-
87-
- uses: actions/cache@v2
88-
with:
89-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
90-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
91-
env:
92-
NAME: libffi
49+
path: ${{ env.BUILD_DIR_PREFIX }}/build-stuff
50+
key: ${{ env.KEY_HEAD }}-${{ hashFiles('libheif/*.*') }}
9351

9452
- name: Start test build
9553
run: cibuildwheel
9654
env:
9755
CIBW_BUILD: ${{ format('cp38-{0}*', matrix.cibw_buildlinux) }}
9856
CIBW_ARCHS: ${{ matrix.cibw_arch }}
99-
CIBW_BEFORE_ALL_LINUX: ${{ env.BUILD_COMMAND }}
100-
CIBW_ENVIRONMENT_PASS_LINUX: BUILD_STUFF LDCONFIG_ARG
57+
CIBW_BEFORE_ALL_LINUX: ${{ env.INSTALL_OS_PACKAGES }}
58+
CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }}
10159
CIBW_TEST_SKIP: "*"
60+
CIBW_BUILD_VERBOSITY: 1
10261

10362
- name: Check builded wheel
10463
run: twine check wheelhouse/*
@@ -109,3 +68,6 @@ jobs:
10968
name: wheels
11069
path: wheelhouse/*.whl
11170
if-no-files-found: error
71+
72+
- name: Fix cache permissions
73+
run: sudo chmod -R 777 ${{ env.BUILD_DIR_PREFIX }}

.github/workflows/create-release-draft.yml

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ jobs:
8282
name: Wheels • ${{ matrix.cibw_buildlinux }} • ${{ matrix.cibw_arch }}
8383
runs-on: ubuntu-20.04
8484
env:
85-
BUILD_STUFF: "/build-stuff"
86-
SCRIPTS: "./build_scripts/linux/"
87-
BUILD_ORDER: "pkg-config,nasm,libde265,aom,libheif,libffi"
85+
BUILD_DIR_PREFIX: "/tmp/pillow_heif"
8886
KEY_HEAD: ${{ matrix.cibw_arch }}-${{ matrix.cibw_buildlinux }}
8987

9088
steps:
@@ -95,80 +93,39 @@ jobs:
9593
with:
9694
platforms: arm64
9795

98-
- name: Preparations
99-
run: |
100-
sudo mkdir "$BUILD_STUFF" && sudo chmod 777 "$BUILD_STUFF"
101-
echo BUILD_STUFF_CMD="&& sh $(echo "$BUILD_ORDER" | sed 's/,/.sh \&\& sh /g').sh" >> $GITHUB_ENV
102-
python3 -m pip install cibuildwheel twine
96+
- name: Install cibuildwheel & twine
97+
run: python3 -m pip install cibuildwheel twine
10398

10499
- name: manylinux preparations
105100
if: matrix.cibw_buildlinux == 'manylinux'
106-
run: |
107-
echo BUILD_COMMAND="yum install -y -q $OS_PACKAGES && set -ex && cd $SCRIPTS $BUILD_STUFF_CMD" >> $GITHUB_ENV
108-
echo LDCONFIG_ARG="" >> $GITHUB_ENV
101+
run: echo INSTALL_OS_PACKAGES="yum update -y && yum install -y $OS_PACKAGES" >> $GITHUB_ENV
109102
env:
110-
OS_PACKAGES: "wget libtool git-all"
103+
OS_PACKAGES: "git-all"
111104

112105
- name: musllinux preparations
113106
if: matrix.cibw_buildlinux == 'musllinux'
114-
run: |
115-
echo BUILD_COMMAND="apk --no-cache add -q $OS_PACKAGES && set -ex && cd $SCRIPTS $BUILD_STUFF_CMD" >> $GITHUB_ENV
116-
echo LDCONFIG_ARG="/usr/lib" >> $GITHUB_ENV
117-
echo CIBW_SKIP="cp36-*" >> $GITHUB_ENV
118-
env:
119-
OS_PACKAGES: "sudo py3-pip python3-dev libtool git \
120-
freetype-dev fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev openjpeg-dev tiff-dev zlib-dev"
121-
122-
- uses: actions/cache@v2
123-
with:
124-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
125-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
126-
env:
127-
NAME: pkg-config
128-
129-
- uses: actions/cache@v2
130-
with:
131-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
132-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
107+
run: echo INSTALL_OS_PACKAGES="apk update && apk --no-cache add $OS_PACKAGES" >> $GITHUB_ENV
133108
env:
134-
NAME: nasm
109+
OS_PACKAGES: "sudo py3-pip python3-dev fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev openjpeg-dev"
135110

136111
- uses: actions/cache@v2
137112
with:
138-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
139-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
140-
env:
141-
NAME: libde265
142-
143-
- uses: actions/cache@v2
144-
with:
145-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
146-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
147-
env:
148-
NAME: aom
149-
150-
- uses: actions/cache@v2
151-
with:
152-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
153-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
154-
env:
155-
NAME: libheif
113+
path: ${{ env.BUILD_DIR_PREFIX }}/build-tools
114+
key: ${{ env.KEY_HEAD }}-${{ hashFiles('libheif/*.py') }}
156115

157116
- uses: actions/cache@v2
158117
with:
159-
path: ${{ env.BUILD_STUFF }}/${{ env.NAME }}
160-
key: ${{ env.KEY_HEAD }}-${{ hashFiles(format('{0}{1}.sh', env.SCRIPTS, env.NAME)) }}
161-
env:
162-
NAME: libffi
118+
path: ${{ env.BUILD_DIR_PREFIX }}/build-stuff
119+
key: ${{ env.KEY_HEAD }}-${{ hashFiles('libheif/*.*') }}
163120

164121
- name: Run cibuildwheel
165122
run: cibuildwheel
166123
env:
167124
CIBW_BUILD: ${{ format('cp3*-{0}*', matrix.cibw_buildlinux) }}
168125
# CIBW_SKIP: "cp36-*"
169126
CIBW_ARCHS: ${{ matrix.cibw_arch }}
170-
CIBW_BEFORE_BUILD_LINUX: ${{ env.BUILD_COMMAND }}
171-
CIBW_ENVIRONMENT_PASS_LINUX: BUILD_STUFF LDCONFIG_ARG
127+
CIBW_BEFORE_ALL_LINUX: ${{ env.INSTALL_OS_PACKAGES }}
128+
CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }}
172129
CIBW_BEFORE_TEST: pip3 install -r requirements_dev.txt
173130
CIBW_TEST_COMMAND: "pytest -s {project}"
174131
CIBW_BUILD_VERBOSITY: 2
@@ -183,6 +140,9 @@ jobs:
183140
path: wheelhouse/*.whl
184141
if-no-files-found: error
185142

143+
- name: Fix cache permissions
144+
run: sudo chmod -R 777 ${{ env.BUILD_DIR_PREFIX }}
145+
186146
sdist:
187147
needs: [wheels_linux, wheels_macos]
188148
name: Source distribution
@@ -214,9 +174,7 @@ jobs:
214174
python3 -m twine check wheelhouse/*
215175
216176
- name: Generate coverage report
217-
run: |
218-
cd .. && coverage run --rcfile=pillow_heif/pyproject.toml -m pytest pillow_heif
219-
cd - && coverage xml --data-file=../.coverage
177+
run: coverage run --rcfile=pyproject.toml -m pytest && coverage xml
220178

221179
- name: Upload report to Codecov
222180
uses: codecov/codecov-action@v2

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.1.7 - 2022-02-27]
6+
7+
### Added
8+
9+
- Added `manylinux2014_i686` wheels.
10+
- Integration of PEP 517 in progress, added new instructions for building from source.
11+
12+
### Changed
13+
14+
- Making code cleaner, renamed cffi module from `pillow_heif.libheif` to `_pillow_heif_cffi`.
15+
- libaom bumped from 3.2.0 to 3.3.0
16+
17+
### Fixed
18+
19+
- Fixed `AttributeError` when calling `Image.verify`. Thanks @zijian-hu for reporting.
20+
521
## [0.1.6 - 2022-02-10]
622

723
### Added

README.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pillow_heif
22

3-
![static-analysis](https://github.com/bigcat88/pillow_heif/actions/workflows/static-analysis.yml/badge.svg)
3+
![analysis](https://github.com/bigcat88/pillow_heif/actions/workflows/analysis-coverage.yml/badge.svg)
44
![build](https://github.com/bigcat88/pillow_heif/actions/workflows/create-release-draft.yml/badge.svg)
55
![published](https://github.com/bigcat88/pillow_heif/actions/workflows/publish-pypi.yaml/badge.svg)
66
[![codecov](https://codecov.io/gh/bigcat88/pillow_heif/branch/master/graph/badge.svg?token=JY64F2OL6V)](https://codecov.io/gh/bigcat88/pillow_heif)
@@ -17,11 +17,11 @@
1717
![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black)
1818
![Alpine Linux](https://img.shields.io/badge/Alpine_Linux-0078D6.svg?style=for-the-badge&logo=alpine-linux&logoColor=white)
1919

20-
A HEIF/HEIC add-on for Pillow using the `libheif` library via `CFFI`.
20+
A HEIF/HEIC/AVIF add-on for Pillow using the `libheif` library via `CFFI`.
2121

22-
Binary wheels for Python 3.6-3.10. Linux(+Alpine)/macOS/Windows - x64/aarch64.
22+
Binary wheels for Python 3.6-3.10. Linux(+Alpine)/macOS/Windows - i686, x86_64 and aarch64.
2323

24-
#### **_Version 0.1.6 was last to support Python 3.6._**
24+
#### **_Version 0.1.9 will be last to support Python 3.6._**
2525

2626
Mostly based on David Poirier's [pyheif](https://github.com/carsales/pyheif).
2727
The idea for this plugin came from Christian Bianciotto's [pyheif-pillow-opener](https://github.com/ciotto/pyheif-pillow-opener).
@@ -33,32 +33,48 @@ Pull requests are greatly welcome.
3333
(Recommended) From [PyPi](https://pypi.org/project/pillow-heif/):
3434

3535
```bash
36-
pip install pillow_heif
36+
pip3 install pillow_heif
3737
```
3838

3939

4040
## Installation from source
41-
**(NOT RECOMMENDED)**(Until finished integration of PEP 517)
41+
_Instructions are valid for version 0.1.7+_
4242

43-
##### Linux Ubuntu
43+
### Linux
44+
45+
#### Debian(Ubuntu):
46+
```bash
47+
sudo apt install -y python3-pip libtool git cmake
48+
sudo -H python3 -m pip install --upgrade pip
49+
sudo -H python3 -m pip install --no-binary pillow_heif
50+
```
51+
52+
53+
#### Alpine:
4454
```bash
45-
sudo add-apt-repository ppa:strukturag/libheif
46-
apt install libffi libheif-dev libde265-dev
47-
pip install git+https://github.com/bigcat88/pillow_heif.git
55+
sudo apk --no-cache add py3-pip python3-dev libtool git gcc m4 perl alpine-sdk cmake
56+
sudo apk --no-cache add fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev openjpeg-dev
57+
sudo -H python3 -m pip install --upgrade pip
58+
sudo -H python3 -m pip install --no-binary pillow_heif
4859
```
4960

50-
##### MacOS
61+
See [build_libs_linux](https://github.com/bigcat88/pillow_heif/blob/master/libheif/build_libs.py) for additional info what will happen during installing from source.
62+
63+
Note: building for first time will take a long time, if in your system `cmake` version `>=3.16.1` is not present.
64+
65+
66+
### MacOS
5167
```bash
68+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
5269
brew install x265 libjpeg libde265 libheif
53-
pip3 install git+https://github.com/bigcat88/pillow_heif.git
70+
pip3 install --no-binary pillow_heif
5471
```
5572

56-
##### Windows
57-
With vcpkg and Visual Studio 2015+ Tools installed:
73+
### Windows
5874
```bat
5975
vcpkg install aom libheif --triplet=x64-windows
6076
VCPKG_PREFIX="path_to:vcpkg/installed/x64-windows"
61-
pip install git+https://github.com/bigcat88/pillow_heif.git
77+
pip3 install --no-binary pillow_heif
6278
```
6379

6480
## Example of use as opener

libheif/build.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,31 @@
22
from sys import platform
33
from subprocess import run, DEVNULL, PIPE
44
from cffi import FFI
5-
6-
ffi = FFI()
5+
from libheif import build_libs
76

87

8+
ffi = FFI()
99
with open("libheif/heif.h", "r", encoding="utf-8") as f:
1010
ffi.cdef(f.read())
1111

12-
13-
include_dirs = ["/usr/local/include", "/usr/include", "/opt/local/include"]
14-
library_dirs = ["/usr/local/lib", "/usr/lib", "/lib", "/opt/local/lib"]
12+
include_dirs = ["/usr/local/include", "/usr/include"]
13+
library_dirs = ["/usr/local/lib", "/usr/lib", "/lib"]
1514

1615
include_path_prefix = ""
16+
insert = False
1717
if platform.lower() == "darwin":
1818
include_path_prefix = getenv("HOMEBREW_PREFIX")
1919
if not include_path_prefix:
2020
_result = run(["brew", "--prefix"], stderr=DEVNULL, stdout=PIPE, check=False)
2121
if not _result.returncode and _result.stdout is not None:
2222
include_path_prefix = _result.stdout.decode("utf-8").rstrip("\n")
23+
if not include_path_prefix:
24+
include_path_prefix = "/opt/local"
2325
elif platform.lower() == "win32":
2426
include_path_prefix = getenv("VCPKG_PREFIX")
27+
else:
28+
include_path_prefix = build_libs.build_libs_linux()
29+
2530
if include_path_prefix:
2631
include_path_prefix_include = path.join(include_path_prefix, "include")
2732
if include_path_prefix_include not in include_dirs:

0 commit comments

Comments
 (0)