Skip to content

Commit 58a9b3a

Browse files
committed
0.1.6
1 parent 5138231 commit 58a9b3a

File tree

9 files changed

+148
-48
lines changed

9 files changed

+148
-48
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ jobs:
3232
echo BUILD_STUFF_CMD="&& sh $(echo "$BUILD_ORDER" | sed 's/,/.sh \&\& sh /g').sh" >> $GITHUB_ENV
3333
python3 -m pip install cibuildwheel twine
3434
35-
- name: manylinux2014 preparations
35+
- name: manylinux preparations
3636
if: matrix.cibw_buildlinux == 'manylinux'
3737
run: |
3838
echo BUILD_COMMAND="yum install -y -q $OS_PACKAGES && set -ex && cd $SCRIPTS $BUILD_STUFF_CMD" >> $GITHUB_ENV
3939
echo LDCONFIG_ARG="" >> $GITHUB_ENV
4040
env:
4141
OS_PACKAGES: "wget libtool git-all"
4242

43-
- name: musllinux_1_1 preparations
43+
- name: musllinux preparations
4444
if: matrix.cibw_buildlinux == 'musllinux'
4545
run: |
4646
echo BUILD_COMMAND="apk --no-cache add -q $OS_PACKAGES && set -ex && cd $SCRIPTS $BUILD_STUFF_CMD" >> $GITHUB_ENV

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/psf/black
9+
rev: 21.6b0
10+
hooks:
11+
- id: black
12+
- repo: https://gitlab.com/pycqa/flake8
13+
rev: 4.0.1
14+
hooks:
15+
- id: flake8
16+
types: [file, python]
17+
#- repo: https://github.com/pre-commit/mirrors-mypy
18+
# rev: v0.782
19+
# hooks:
20+
# - id: mypy
21+
# files: pillow_heif/
22+
# additional_dependencies: [pytest==6.2.4]

.pylintrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ confidence=
5050
# --enable=similarities". If you want to run only the classes checker, but have
5151
# no Warning level messages displayed, use "--disable=all --enable=classes
5252
# --disable=W".
53-
disable=C0114,
54-
C0115,
55-
C0116,
56-
R0401
53+
disable=C0115,
54+
C0116
5755

5856
# Enable the message, report, category or checker with the given id(s). You can
5957
# either give multiple identifier separated by comma (,) or put this option
@@ -293,7 +291,7 @@ indent-after-paren=4
293291
indent-string=' '
294292

295293
# Maximum number of characters on a single line.
296-
max-line-length=130
294+
max-line-length=120
297295

298296
# Maximum number of lines in a module.
299297
max-module-lines=1000

CHANGELOG.md

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

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

5+
## [0.1.6 - 2022-02-10]
6+
7+
### Added
8+
9+
- Windows binary wheels.
10+
- More tests to `as_opener` module.
11+
- Code coverage.
12+
- Linux binary wheels for Python 3.6(this is last release for Python 3.6).
13+
14+
### Changed
15+
16+
- Using code formatting: black.
17+
- Started changing build algorithms to support PEP 517.
18+
- Speed optimizations and adjustments to `as_opener` module.
19+
- Added `info[icc_profile]` to `HeifImageFile` when use it as `as_opener`.
20+
- Adjustments to `reader` module:
21+
- `pillow_heif.open` is in process of deprecation, still available, but you should use `open_heif` instead.
22+
- `pillow_heif.check` is in process of deprecation, still available, but you should use `check_heif` instead.
23+
- `pillow_heif.read` is in process of deprecation, still available, but you should use `read_heif` instead.
24+
25+
### Fixed
26+
27+
- Apple M1 binary wheels now build on Monterey 12.01 instead of 12.2.
28+
- HeifError exception class now calls `super` to init all values.
29+
530
## [0.1.5 - 2022-02-01]
631

732
### Added
@@ -23,15 +48,15 @@ All notable changes to this project will be documented in this file.
2348

2449
- GitHub build Actions now use cache.
2550
- Added `libaom` library to linux build.
26-
- More tests.
51+
- More tests.
2752

2853
### Changed
2954

3055
- Code refactoring, readme update.
3156

3257
### Fixed
3358

34-
- Bug with header check when used as plugin for Pillow with `as_opener` function. Thanks for this to @DimonLavron
59+
- Bug with header check when used as plugin for Pillow with `as_opener` function. Thanks for this to @DimonLavron
3560

3661
## [0.1.3 - 2021-10-25]
3762

MANIFEST.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
include libheif/*
22
include README.md
33
include CHANGELOG.md
4-
include pytest.ini
54
include requirements.txt
65
include requirements_dev.txt
6+
include pyproject.toml
77

88
graft tests
99

1010
exclude .pylintrc
11+
exclude .pre-commit-config.yaml
1112

12-
prune build_scripts
13+
prune build_scripts

libheif/build.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,47 @@
33
from subprocess import run, DEVNULL, PIPE
44
from cffi import FFI
55

6-
ffibuilder = FFI()
6+
ffi = FFI()
77

88

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

1212

1313
include_dirs = ["/usr/local/include", "/usr/include", "/opt/local/include"]
1414
library_dirs = ["/usr/local/lib", "/usr/lib", "/lib", "/opt/local/lib"]
1515

16+
if platform.lower() in ("darwin", "win32"):
17+
include_dirs.append(path.dirname(path.dirname(path.abspath(__file__))))
18+
19+
include_path_prefix = ""
1620
if platform.lower() == "darwin":
17-
homebrew_prefix = getenv("HOMEBREW_PREFIX")
18-
if not homebrew_prefix:
19-
_result = run(['brew', '--prefix'], stderr=DEVNULL, stdout=PIPE, check=False)
21+
include_path_prefix = getenv("HOMEBREW_PREFIX")
22+
if not include_path_prefix:
23+
_result = run(["brew", "--prefix"], stderr=DEVNULL, stdout=PIPE, check=False)
2024
if not _result.returncode and _result.stdout is not None:
21-
homebrew_prefix = _result.stdout.decode('utf-8').rstrip('\n')
22-
if homebrew_prefix:
23-
homebrew_include = path.join(homebrew_prefix, "include")
24-
if homebrew_include not in include_dirs:
25-
include_dirs.append(homebrew_include)
26-
homebrew_library = path.join(homebrew_prefix, "lib")
27-
if homebrew_library not in library_dirs:
28-
library_dirs.append(homebrew_library)
29-
project_root = path.dirname(path.dirname(path.abspath(__file__)))
30-
include_dirs.append(project_root)
31-
32-
33-
ffibuilder.set_source(
34-
"pillow_heif._libheif",
25+
include_path_prefix = _result.stdout.decode("utf-8").rstrip("\n")
26+
elif platform.lower() == "win32":
27+
include_path_prefix = getenv("VCPKG_PREFIX")
28+
if include_path_prefix:
29+
include_path_prefix_include = path.join(include_path_prefix, "include")
30+
if include_path_prefix_include not in include_dirs:
31+
include_dirs.append(include_path_prefix_include)
32+
include_path_prefix_lib = path.join(include_path_prefix, "lib")
33+
if include_path_prefix_lib not in library_dirs:
34+
library_dirs.append(include_path_prefix_lib)
35+
36+
37+
ffi.set_source(
38+
"pillow_heif.libheif",
3539
"""
3640
#include "libheif/heif.h"
3741
""",
3842
include_dirs=include_dirs,
3943
library_dirs=library_dirs,
4044
libraries=["heif"],
45+
extra_compile_args=["/d2FH4-"] if platform.lower() == "win32" else [],
4146
)
4247

4348
if __name__ == "__main__":
44-
ffibuilder.compile(verbose=True)
49+
ffi.compile(verbose=True)

pyproject.toml

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
1-
[tool.cibuildwheel.macos]
2-
before-all = [
3-
"brew install x265 libjpeg libde265 libheif",
4-
"HOMEBREW_PREFIX=$(brew --prefix)",
5-
"REPAIR_LIBRARY_PATH=$HOMEBREW_PREFIX/lib",
6-
"echo $REPAIR_LIBRARY_PATH",
7-
]
1+
#[build-system]
2+
#requires = [
3+
# "setuptools>=41.2.0",
4+
# "cffi>=1.14.0",
5+
#]
6+
#build-backend = "setuptools.build_meta"
7+
#
8+
#[metadata]
9+
10+
[tool.coverage.run]
11+
cover_pylib = true
12+
include = ["*/pillow_heif/*"]
13+
omit = ["*/tests/*"]
814

9-
repair-wheel-command = [
10-
"DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel}",
11-
"DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel -v --require-archs {delocate_archs} -w {dest_dir} {wheel}",
15+
[tool.coverage.report]
16+
exclude_lines = [
17+
"pragma: no cover",
18+
"raise NotImplementedError",
19+
"DeprecationWarning"
1220
]
1321

14-
[tool.cibuildwheel.windows]
15-
before-all = [ ]
22+
[tool.black]
23+
line-length = 120
24+
target-versions = ["py38"]
25+
include = '\.pyi?$'
26+
exclude = '''
27+
/(
28+
\.eggs
29+
| \.git
30+
| \.venv
31+
| \.vienv
32+
| \.env
33+
| \.mypy_cache
34+
| \.pytest_cache
35+
| __pycache__
36+
| build
37+
| dist
38+
| wheelhouse
39+
)\
40+
'''
1641

17-
#set INCLUDE=%INCLUDE%;X:\path\to\libheif\source
18-
#set LIB=%LIB%;X:\path\to\libheif\build
42+
[tool.mypy]
43+
ignore_missing_imports = true
44+
allow_redefinition = true
45+
warn_no_return = true
46+
strict_optional = true
47+
48+
[tool.pytest.ini_options]
49+
minversion = "6.0"
50+
testpaths = [
51+
"tests",
52+
]
53+
addopts = "--ignore=memory_leaks.py"

pytest.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
max-line-length = 120
3+
target-version = ["py38"]
4+
ignore = C0116, E203
5+
6+
per-file-ignores =
7+
__init__.py: F401, F403
8+
9+
exclude =
10+
.eggs,
11+
.git,
12+
__pycache__",
13+
build",
14+
dist,
15+
wheelhouse,
16+
*.h,
17+
*.egg

0 commit comments

Comments
 (0)