commit:     0e024beadac3ccaefb4a3961214eb74ee5853cf2
Author:     Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com>
AuthorDate: Mon Mar 25 07:30:51 2024 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Wed Mar 27 10:12:48 2024 +0000
URL:        https://gitweb.gentoo.org/proj/sci.git/commit/?id=0e024bea

sci-libs/torchvision: add 0.17.1

Other changes compared to previous version:

1. Include a patch for ffmpeg 6.0 fix
2. Limit setuptools thread to 1, while ninja respect MAKEOPTS
3. revdump on ffmpeg because video_reader.so links to libavutil
   libavcodec libavformat
4. Drop dev-qt/qtcore dependency since not needed
5. Drop test support: missing dependency expecttest, problematic import
   issues: https://github.com/gentoo/sci/pull/1263#issuecomment-2021380600

Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
Closes: https://github.com/gentoo/sci/pull/1263
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../files/torchvision-0.17.1-ffmpeg-6.patch        | 36 +++++++++++++++++
 sci-libs/torchvision/torchvision-0.17.1.ebuild     | 45 ++++++++++++++++++++++
 2 files changed, 81 insertions(+)

diff --git a/sci-libs/torchvision/files/torchvision-0.17.1-ffmpeg-6.patch 
b/sci-libs/torchvision/files/torchvision-0.17.1-ffmpeg-6.patch
new file mode 100644
index 000000000..7a3637f3a
--- /dev/null
+++ b/sci-libs/torchvision/files/torchvision-0.17.1-ffmpeg-6.patch
@@ -0,0 +1,36 @@
+From 86620bd84b872b76db0acafec167949dca03a29e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
+ <[email protected]>
+Date: Tue, 7 Nov 2023 10:43:11 +0100
+Subject: [PATCH] Fix build with ffmpeg 6.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Zoltán Böszörményi <[email protected]>
+---
+ torchvision/csrc/io/decoder/stream.cpp | 11 ++---------
+ 1 file changed, 2 insertions(+), 9 deletions(-)
+
+diff --git a/torchvision/csrc/io/decoder/stream.cpp 
b/torchvision/csrc/io/decoder/stream.cpp
+index 0d625ef211c..8c914050587 100644
+--- a/torchvision/csrc/io/decoder/stream.cpp
++++ b/torchvision/csrc/io/decoder/stream.cpp
+@@ -63,15 +63,8 @@ int Stream::openCodec(std::vector<DecoderMetadata>* 
metadata, int num_threads) {
+     codecCtx_->thread_count = num_threads;
+   } else {
+     // otherwise set sensible defaults
+-    // with the special case for the different MPEG4 codecs
+-    // that don't have threading context functions
+-    if (codecCtx_->codec->capabilities & AV_CODEC_CAP_INTRA_ONLY) {
+-      codecCtx_->thread_type = FF_THREAD_FRAME;
+-      codecCtx_->thread_count = 2;
+-    } else {
+-      codecCtx_->thread_count = 8;
+-      codecCtx_->thread_type = FF_THREAD_SLICE;
+-    }
++    codecCtx_->thread_count = 8;
++    codecCtx_->thread_type = FF_THREAD_SLICE;
+   }
+ 
+   int ret;

diff --git a/sci-libs/torchvision/torchvision-0.17.1.ebuild 
b/sci-libs/torchvision/torchvision-0.17.1.ebuild
new file mode 100644
index 000000000..e0c72684c
--- /dev/null
+++ b/sci-libs/torchvision/torchvision-0.17.1.ebuild
@@ -0,0 +1,45 @@
+# Copyright 2020-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..12} )
+DISTUTILS_SINGLE_IMPL=1
+DISTUTILS_USE_PEP517=setuptools
+DISTUTILS_EXT=1
+inherit distutils-r1 multiprocessing
+
+DESCRIPTION="Datasets, transforms and models to specific to computer vision"
+HOMEPAGE="https://github.com/pytorch/vision";
+SRC_URI="https://github.com/pytorch/vision/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+S="${WORKDIR}/vision-${PV}"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64"
+RESTRICT="test"
+
+RDEPEND="
+       $(python_gen_cond_dep '
+               dev-python/numpy[${PYTHON_USEDEP}]
+               dev-python/typing-extensions[${PYTHON_USEDEP}]
+               dev-python/pillow[${PYTHON_USEDEP}]
+               dev-python/requests[${PYTHON_USEDEP}]
+               dev-python/scipy[${PYTHON_USEDEP}]
+       ')
+       sci-libs/pytorch[${PYTHON_SINGLE_USEDEP}]
+       media-video/ffmpeg:=
+"
+DEPEND="${RDEPEND}"
+
+PATCHES=( "${FILESDIR}/${PN}-0.17.1-ffmpeg-6.patch" )
+
+src_compile()
+{
+       export MAX_JOBS="$(makeopts_jobs)" # Let ninja respect MAKEOPTS
+
+       # Ensure some ext_module sources are compiled before linking
+       export MAKEOPTS="-j1"
+
+       distutils-r1_src_compile
+}

Reply via email to