diff --git a/multimedia/py-torchcodec/Makefile b/multimedia/py-torchcodec/Makefile index 7f06c3fe726f..3df579a21b86 100644 --- a/multimedia/py-torchcodec/Makefile +++ b/multimedia/py-torchcodec/Makefile @@ -1,41 +1,54 @@ PORTNAME= torchcodec DISTVERSIONPREFIX= v -DISTVERSION= 0.13.0 +DISTVERSION= 0.16.0 CATEGORIES= multimedia python #MASTER_SITES= PYPI # no tarball PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} MAINTAINER= yuri@FreeBSD.org COMMENT= PyTorch media decoding and encoding WWW= https://github.com/pytorch/torchcodec LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/LICENSE -BROKEN= Fails to build with FFmpeg 9 - -BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR} \ - ${PY_SETUPTOOLS} \ - ${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR} \ - pybind11>0:devel/pybind11 +BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pybind11>0:devel/py-pybind11@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}scikit-build-core>0:devel/py-scikit-build-core@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR} LIB_DEPENDS= libabsl_base.so:devel/abseil \ libavformat.so:multimedia/ffmpeg \ - libprotobuf.so:devel/protobuf + libavif.so:graphics/libavif \ + libheif.so:graphics/libheif \ + libpng16.so:graphics/png \ + libprotobuf.so:devel/protobuf \ + libwebp.so:graphics/webp RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}torchvision>0:misc/py-torchvision@${PY_FLAVOR} TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}numpy>=1.16:math/py-numpy@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pillow>=0:graphics/py-pillow@${PY_FLAVOR} -USES= cmake:indirect compiler:c++17-lang python +USES= cmake:indirect compiler:c++17-lang jpeg localbase pkgconfig python USE_PYTHON= pep517 autoplist pytest USE_GITHUB= yes GH_ACCOUNT= meta-pytorch +CMAKE_ARGS= -DCMAKE_MODULE_PATH=${WRKSRC}/cmake +CONFIGURE_ENV= WRKSRC=${WRKSRC} # for cmake module + #MAKE_ENV= BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 # downloads binaries with this choice, see https://github.com/meta-pytorch/torchcodec/issues/1194 MAKE_ENV= I_CONFIRM_THIS_IS_NOT_A_LICENSE_VIOLATION=1 +MAKE_ENV+= TORCHCODEC_BUILD_WEBP=0 # TODO figure out why WebP isn't discovered by cmake despite out FindWebP.cmake +MAKE_ENV+= TORCHCODEC_BUILD_AVIF=0 # TODO avif_s3 binaries are fetched intead of using a package, see https://github.com/AOMediaCodec/libavif/issues/3362 TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} +TEST_ARGS= --disable-plugin-autoload + +post-patch: + ${MKDIR} ${WRKSRC}/cmake + @${CP} ${FILESDIR}/FindWebP.cmake ${WRKSRC}/cmake + @${REINPLACE_CMD} -e 's|%%WRKSRC%%|${WRKSRC}|' ${WRKSRC}/src/torchcodec/_core/CMakeLists.txt -# tests as of 0.13.0: 293 failed, 1527 passed, 745 skipped in 515.40s (0:08:35) +# tests as of 0.16.0: 4 failed, 1864 passed, 815 skipped, 4 warnings in 321.82s (0:05:21) # all failures are related to missing frames, see https://github.com/meta-pytorch/torchcodec/issues/1709 .include diff --git a/multimedia/py-torchcodec/distinfo b/multimedia/py-torchcodec/distinfo index 3f75828b1b49..a243d30d49eb 100644 --- a/multimedia/py-torchcodec/distinfo +++ b/multimedia/py-torchcodec/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1780432436 -SHA256 (meta-pytorch-torchcodec-v0.13.0_GH0.tar.gz) = acc955dbd7b80dcb6268fd3ff728477af0ba7fd79b4251c1ef685fdd5e2229e4 -SIZE (meta-pytorch-torchcodec-v0.13.0_GH0.tar.gz) = 14295989 +TIMESTAMP = 1788978327 +SHA256 (meta-pytorch-torchcodec-v0.16.0_GH0.tar.gz) = b10068c6c52205bc10bec0bba350079b34ecc1880727e89fc8a13951d59c7bf1 +SIZE (meta-pytorch-torchcodec-v0.16.0_GH0.tar.gz) = 17385828 diff --git a/multimedia/py-torchcodec/files/FindWebP.cmake b/multimedia/py-torchcodec/files/FindWebP.cmake new file mode 100644 index 000000000000..ae8952f787a8 --- /dev/null +++ b/multimedia/py-torchcodec/files/FindWebP.cmake @@ -0,0 +1,38 @@ +# cmake/FindWebP.cmake +find_package(PkgConfig REQUIRED) + +# 1. Look for core webp +pkg_check_modules(PC_WEBP QUIET libwebp) +find_path(WebP_INCLUDE_DIR NAMES webp/decode.h HINTS ${PC_WEBP_INCLUDEDIR}) +find_library(WebP_LIBRARY NAMES webp HINTS ${PC_WEBP_LIBDIR}) + +# 2. Look for webpdemux +pkg_check_modules(PC_WEBP_DEMUX QUIET libwebpdemux) +find_path(WebP_DEMUX_INCLUDE_DIR NAMES webp/demux.h HINTS ${PC_WEBP_DEMUX_INCLUDEDIR}) +find_library(WebP_DEMUX_LIBRARY NAMES webpdemux HINTS ${PC_WEBP_DEMUX_LIBDIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WebP DEFAULT_MSG + WebP_LIBRARY WebP_INCLUDE_DIR + WebP_DEMUX_LIBRARY WebP_DEMUX_INCLUDE_DIR +) + +# Define the WebP::webp target +if(WebP_FOUND AND NOT TARGET WebP::webp) + add_library(WebP::webp UNKNOWN IMPORTED) + set_target_properties(WebP::webp PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" + IMPORTED_LOCATION "${WebP_LIBRARY}" + ) +endif() + +# Define the WebP::webpdemux target expected by torchcodec +if(WebP_FOUND AND NOT TARGET WebP::webpdemux) + add_library(WebP::webpdemux UNKNOWN IMPORTED) + set_target_properties(WebP::webpdemux PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${WebP_DEMUX_INCLUDE_DIR}" + IMPORTED_LOCATION "${WebP_DEMUX_LIBRARY}" + INTERFACE_LINK_LIBRARIES WebP::webp + ) +endif() + diff --git a/multimedia/py-torchcodec/files/patch-pyproject.toml b/multimedia/py-torchcodec/files/patch-pyproject.toml index 4020df9ab5d7..5187be45ae87 100644 --- a/multimedia/py-torchcodec/files/patch-pyproject.toml +++ b/multimedia/py-torchcodec/files/patch-pyproject.toml @@ -1,13 +1,29 @@ -- Remove invalid license-files property from pyproject.toml. -- The license-files property is not supported by the version of setuptools available on FreeBSD, causing a build failure. It is a relatively new PEP 639 feature. ---- pyproject.toml.orig 2026-06-02 20:36:38 UTC +--- pyproject.toml.orig 2026-08-13 07:10:38 UTC +++ pyproject.toml @@ -3,7 +3,6 @@ requires-python = ">=3.10" description = "A video decoder for PyTorch" readme = "README.md" requires-python = ">=3.10" -license-files = ["LICENSE"] authors = [ { name = "PyTorch Team", email = "packages@pytorch.org" }, ] +@@ -18,6 +17,7 @@ build-backend = "scikit_build_core.build" + build-backend = "scikit_build_core.build" + + [tool.scikit-build] ++cmake.args = ["--trace-expand"] + minimum-version = "build-system.requires" + build-dir = "build/{wheel_tag}" + wheel.packages = ["src/torchcodec"] +@@ -48,6 +48,7 @@ location = "source" + path = "src/torchcodec/version.py" + template = "__version__ = '${version}'" + location = "source" ++ + + [tool.scikit-build.cmake.define] + ENABLE_CUDA = {env = "ENABLE_CUDA", default = ""} diff --git a/multimedia/py-torchcodec/files/patch-src_torchcodec___core_CMakeLists.txt b/multimedia/py-torchcodec/files/patch-src_torchcodec___core_CMakeLists.txt new file mode 100644 index 000000000000..e69ef97c2bc0 --- /dev/null +++ b/multimedia/py-torchcodec/files/patch-src_torchcodec___core_CMakeLists.txt @@ -0,0 +1,21 @@ +--- src/torchcodec/_core/CMakeLists.txt.orig 2026-08-13 07:10:38 UTC ++++ src/torchcodec/_core/CMakeLists.txt +@@ -3,6 +3,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + ++list(APPEND CMAKE_MODULE_PATH %%WRKSRC%%/torchcodec-0.16.0/cmake) ++message(STATUS "YURI: Current module path: ${CMAKE_MODULE_PATH}") + # Guard against accidentally building a distributable wheel that dynamically + # links against a GPL build of FFmpeg (e.g. from conda/system), which would be a + # license violation. Wheels are expected to link against our pre-built non-GPL +@@ -123,7 +125,9 @@ function(discover_image_codecs) + set(WebP_ROOT "$ENV{CONDA_PREFIX}") + endif() + endif() ++ message(STATUS "YURI >>> WebP_FOUND=${WebP_FOUND} WebP_ROOT=${WebP_ROOT}") + find_package(WebP) # Provides the WebP::webp and WebP::webpdemux targets. ++ message(STATUS "YURI <<< WebP_FOUND=${WebP_FOUND} WebP_ROOT=${WebP_ROOT}") + if(WebP_FOUND) + message(STATUS "libwebp found: building torchcodec with WebP image decoding support.") + else()