Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Nov 9, 2023
1 parent fb054d9 commit ea21c50
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 45 deletions.
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ def readme():
IS_DEBUG = hasattr(sys, "gettotalrefcount")
PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version

libraries = ["avif"]
if sys.platform == "win32":
libraries.extend(
[
"advapi32",
"bcrypt",
"ntdll",
"userenv",
"ws2_32",
"kernel32",
]
)

setup(
name="pillow-avif-plugin",
description="A pillow plugin that adds avif support via libavif",
Expand All @@ -39,7 +52,7 @@ def readme():
"pillow_avif._avif",
["src/pillow_avif/_avif.c"],
depends=["avif/avif.h"],
libraries=["avif"],
libraries=libraries,
),
],
package_data={"": ["README.rst"]},
Expand Down
3 changes: 1 addition & 2 deletions wheelbuild/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ set -eo pipefail
CONFIG_DIR=$(abspath $(dirname "${BASH_SOURCE[0]}"))

ARCHIVE_SDIR=pillow-avif-plugin-depends
LIBAVIF_VERSION=bef0bcb9613769ca3706b82c0c9e477b7711f42e
DAV1D_VERSION=1.2.1
LIBAVIF_VERSION=0014b9a89524c4c503bde2ce03face83640902b8
RAV1E_VERSION=p20231003
CCACHE_VERSION=4.7.1
SCCACHE_VERSION=0.3.0
Expand Down
8 changes: 8 additions & 0 deletions winbuild/Findrav1e.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
file(TO_CMAKE_PATH "${AVIF_RAV1E_ROOT}" RAV1E_ROOT_PATH)
add_library(rav1e STATIC IMPORTED GLOBAL)
set_target_properties(rav1e PROPERTIES
IMPORTED_LOCATION "${RAV1E_ROOT_PATH}/lib/rav1e.lib"
AVIF_LOCAL ON
INTERFACE_INCLUDE_DIRECTORIES "${RAV1E_ROOT_PATH}/inc/rav1e"
)
add_library(rav1e::rav1e ALIAS rav1e)
77 changes: 35 additions & 42 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,54 +180,46 @@ def cmd_msbuild(
},
"libavif": {
"url": (
"https://github.com/AOMediaCodec/libavif/archive/"
"a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa.zip"
"https://github.com/fdintino/libavif/archive/"
"0014b9a89524c4c503bde2ce03face83640902b8.zip"
),
"filename": "libavif-a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa.zip",
"dir": "libavif-a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa",
"filename": "libavif-0014b9a89524c4c503bde2ce03face83640902b8.zip",
"dir": "libavif-0014b9a89524c4c503bde2ce03face83640902b8",
"license": "LICENSE",
"build": [
cmd_mkdir(r"ext\rav1e\build.libavif\usr"),
cmd_xcopy(r"..\rav1e-windows-msvc-sdk", r"ext\rav1e\build.libavif\usr"),
cmd_cd("ext"),
"@echo ::group::Building SVT-AV1",
cmd_rmdir("SVT-AV1"),
"cmd.exe /c svt.cmd",
"@echo ::endgroup::",
"@echo ::group::Building aom",
cmd_rmdir("aom"),
'cmd.exe /c "aom.cmd"',
"@echo ::endgroup::",
"@echo ::group::Building dav1d",
cmd_rmdir("dav1d"),
'cmd.exe /c "dav1d.cmd"',
"@echo ::endgroup::",
"@echo ::group::Building libyuv",
cmd_rmdir("libyuv"),
'cmd.exe /c "libyuv.cmd"',
"@echo ::endgroup::",
"@echo ::group::Building libsharpyuv",
cmd_rmdir("libsharpyuv"),
'cmd.exe /c "libsharpyuv.cmd"',
"@echo ::endgroup::",
"@echo ::group::Building libavif",
cmd_cd(".."),
*cmds_cmake(
"avif",
"-DBUILD_SHARED_LIBS=OFF",
"-DAVIF_CODEC_AOM=ON",
"-DAVIF_LOCAL_AOM=ON",
"-DAVIF_LOCAL_LIBYUV=ON",
"-DAVIF_LOCAL_LIBSHARPYUV=ON",
"-DAVIF_CODEC_RAV1E=ON",
"-DAVIF_CODEC_DAV1D=ON",
"-DAVIF_LOCAL_DAV1D=ON",
"-DAVIF_CODEC_SVT=ON",
"-DAVIF_LOCAL_SVT=ON",
cmd_mkdir("build.pillow"),
cmd_cd("build.pillow"),
" ".join(
[
"{cmake}",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_VERBOSE_MAKEFILE=ON",
"-DCMAKE_RULE_MESSAGES:BOOL=OFF", # for NMake
"-DCMAKE_C_COMPILER=cl.exe", # for Ninja
"-DCMAKE_CXX_COMPILER=cl.exe", # for Ninja
"-DCMAKE_C_FLAGS=-nologo",
"-DCMAKE_CXX_FLAGS=-nologo",
"-DBUILD_SHARED_LIBS=OFF",
"-DAVIF_CODEC_AOM=ON",
"-DAVIF_LOCAL_AOM=ON",
"-DAVIF_LOCAL_LIBYUV=ON",
"-DAVIF_LOCAL_LIBSHARPYUV=ON",
"-DAVIF_CODEC_RAV1E=ON",
"-DAVIF_RAV1E_ROOT={build_dir}",
"-DCMAKE_MODULE_PATH={winbuild_dir_cmake}",
"-DAVIF_CODEC_DAV1D=ON",
"-DAVIF_LOCAL_DAV1D=ON",
"-DAVIF_CODEC_SVT=ON",
"-DAVIF_LOCAL_SVT=ON",
'-G "Ninja"',
"..",
]
),
"ninja -v",
cmd_cd(".."),
cmd_xcopy("include", "{inc_dir}"),
],
"libs": [r"avif.lib"],
"libs": [r"build.pillow\avif.lib"],
},
}

Expand Down Expand Up @@ -562,6 +554,7 @@ def install_meson():
# Pillow paths
"pillow_dir": pillow_dir,
"winbuild_dir": winbuild_dir,
"winbuild_dir_cmake": winbuild_dir.replace("\\", "/"),
# Build paths
"build_dir": args.build_dir,
"inc_dir": inc_dir,
Expand Down

0 comments on commit ea21c50

Please sign in to comment.