diff --git a/setup.py b/setup.py index 0d1f4b9..a761789 100644 --- a/setup.py +++ b/setup.py @@ -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.lib", + "bcrypt.lib", + "ntdll.lib", + "userenv.lib", + "ws2_32.lib", + "kernel32.lib", + ] + ) + setup( name="pillow-avif-plugin", description="A pillow plugin that adds avif support via libavif", @@ -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"]}, diff --git a/wheelbuild/config.sh b/wheelbuild/config.sh index 16c307d..1684327 100644 --- a/wheelbuild/config.sh +++ b/wheelbuild/config.sh @@ -4,7 +4,7 @@ set -eo pipefail CONFIG_DIR=$(abspath $(dirname "${BASH_SOURCE[0]}")) ARCHIVE_SDIR=pillow-avif-plugin-depends -LIBAVIF_VERSION=bef0bcb9613769ca3706b82c0c9e477b7711f42e +LIBAVIF_VERSION=7414dd89e7a989f8cfc1646c0d972731d3236ede DAV1D_VERSION=1.2.1 RAV1E_VERSION=p20231003 CCACHE_VERSION=4.7.1 diff --git a/winbuild/Findrav1e.cmake b/winbuild/Findrav1e.cmake new file mode 100644 index 0000000..c3a75c2 --- /dev/null +++ b/winbuild/Findrav1e.cmake @@ -0,0 +1,7 @@ +add_library(rav1e STATIC IMPORTED GLOBAL) +set_target_properties(rav1e PROPERTIES + IMPORTED_LOCATION "${AVIF_RAV1E_ROOT}/lib/rav1e.lib" + AVIF_LOCAL ON + INTERFACE_INCLUDE_DIRECTORIES "${AVIF_RAV1E_ROOT}/include/rav1e" +) +add_library(rav1e::rav1e ALIAS rav1e) diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 27dd90d..bec39e6 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -180,38 +180,13 @@ def cmd_msbuild( }, "libavif": { "url": ( - "https://github.com/AOMediaCodec/libavif/archive/" - "a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa.zip" + "https://github.com/fdintino/libavif/archive/" + "7414dd89e7a989f8cfc1646c0d972731d3236ede.zip" ), - "filename": "libavif-a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa.zip", - "dir": "libavif-a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa", + "filename": "libavif-7414dd89e7a989f8cfc1646c0d972731d3236ede.zip", + "dir": "libavif-7414dd89e7a989f8cfc1646c0d972731d3236ede", "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", @@ -220,6 +195,8 @@ def cmd_msbuild( "-DAVIF_LOCAL_LIBYUV=ON", "-DAVIF_LOCAL_LIBSHARPYUV=ON", "-DAVIF_CODEC_RAV1E=ON", + "-DAVIF_RAV1E_ROOT={build_dir}", + "-DCMAKE_MODULE_PATH={winbuild_dir}", "-DAVIF_CODEC_DAV1D=ON", "-DAVIF_LOCAL_DAV1D=ON", "-DAVIF_CODEC_SVT=ON",