commit: 521bb020622760d0d4757085f38bd0994edc696c
Author: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 25 18:34:32 2025 +0000
Commit: Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sat Oct 25 18:34:46 2025 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=521bb020
sci-ml/pytorch: add 2.9.0
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>
sci-ml/pytorch/Manifest | 1 +
.../files/pytorch-2.9.0-dontbuildagain.patch | 25 ++++++++
sci-ml/pytorch/pytorch-2.9.0.ebuild | 73 ++++++++++++++++++++++
3 files changed, 99 insertions(+)
diff --git a/sci-ml/pytorch/Manifest b/sci-ml/pytorch/Manifest
index 3a08f977abda..396715e4aafe 100644
--- a/sci-ml/pytorch/Manifest
+++ b/sci-ml/pytorch/Manifest
@@ -1 +1,2 @@
DIST pytorch-2.8.0.tar.gz 56565754 BLAKE2B
a8f07513b92f9293f8322508f9fc73a462f89fe51cb1f280af371cee19cbe7e2bf900ba2b3c43fd08ea415566db441a6d6310d77f18477e957641be311a361a5
SHA512
448e9dad4aa10f1793d35e6ffe9f0f69b7719d41e6eccceb687a8d0c148e22d03e4f76170a05308ef9323a7aea41aa74605077ae1d68c6d949f13b3340ebf310
+DIST pytorch-2.9.0.tar.gz 55750268 BLAKE2B
943459ec60a4e1f5e36766defc7018fbf9722fb1564b723c2a7ebcb2a5d8b1735f0b1542dc67a77f788af3e2454ea6261dbdee5beb2bcfa4af2e58ca566edc93
SHA512
2ecdc0eac39ecee68b0f4c98e498424cde00c45bbeeff576c8778046f97119cd02885498b072352dd3cdd9aecd02baf61cdc5554bce8d757b30c673053a0cc80
diff --git a/sci-ml/pytorch/files/pytorch-2.9.0-dontbuildagain.patch
b/sci-ml/pytorch/files/pytorch-2.9.0-dontbuildagain.patch
new file mode 100644
index 000000000000..9420582ca209
--- /dev/null
+++ b/sci-ml/pytorch/files/pytorch-2.9.0-dontbuildagain.patch
@@ -0,0 +1,25 @@
+--- a/setup.py
++++ b/setup.py
+@@ -291,6 +291,7 @@
+ import setuptools.errors
+ from setuptools import Command, Extension, find_packages, setup
+ from setuptools.dist import Distribution
++sys.path[:0] = os.getcwd()
+
+
+ CWD = Path(__file__).absolute().parent
+@@ -483,14 +483,6 @@
+
+ check_submodules()
+ check_pydep("yaml", "pyyaml")
+- build_pytorch(
+- version=TORCH_VERSION,
+- cmake_python_library=CMAKE_PYTHON_LIBRARY.as_posix(),
+- build_python=not BUILD_LIBTORCH_WHL,
+- rerun_cmake=RERUN_CMAKE,
+- cmake_only=CMAKE_ONLY,
+- cmake=cmake,
+- )
+
+ if CMAKE_ONLY:
+ report(
diff --git a/sci-ml/pytorch/pytorch-2.9.0.ebuild
b/sci-ml/pytorch/pytorch-2.9.0.ebuild
new file mode 100644
index 000000000000..f1c9c11b126e
--- /dev/null
+++ b/sci-ml/pytorch/pytorch-2.9.0.ebuild
@@ -0,0 +1,73 @@
+# Copyright 2022-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{11..13} )
+DISTUTILS_SINGLE_IMPL=1
+DISTUTILS_EXT=1
+inherit distutils-r1 prefix
+
+DESCRIPTION="Tensors and Dynamic neural networks in Python"
+HOMEPAGE="https://pytorch.org/"
+SRC_URI="https://github.com/pytorch/${PN}/archive/refs/tags/v${PV}.tar.gz
+ -> ${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64"
+RESTRICT="test"
+
+REQUIRED_USE=${PYTHON_REQUIRED_USE}
+RDEPEND="
+ ${PYTHON_DEPS}
+ ~sci-ml/caffe2-${PV}[${PYTHON_SINGLE_USEDEP}]
+ $(python_gen_cond_dep '
+ dev-python/sympy[${PYTHON_USEDEP}]
+ dev-python/typing-extensions[${PYTHON_USEDEP}]
+ ')
+"
+DEPEND="${RDEPEND}
+ $(python_gen_cond_dep '
+ dev-python/pyyaml[${PYTHON_USEDEP}]
+ ')
+"
+
+PATCHES=(
+ "${FILESDIR}"/${P}-dontbuildagain.patch
+ "${FILESDIR}"/${PN}-2.7.1-cpp-extension-multilib.patch
+)
+
+src_prepare() {
+ # Replace placeholders added by cpp-extension.patch
+ sed -e "s|%LIB_DIR%|$(get_libdir)|g" \
+ -i torch/utils/cpp_extension.py || die
+
+ # Set build dir for pytorch's setup
+ sed -e "/BUILD_DIR/s|build|/var/lib/caffe2/|" \
+ -i tools/setup_helpers/env.py || die
+
+ # Drop legacy from pyproject.toml
+ sed -e "/build-backend/s|:__legacy__||" \
+ -i pyproject.toml || die
+
+ distutils-r1_src_prepare
+
+ # Get object file from caffe2
+ cp "${ESYSROOT}"/var/lib/caffe2/functorch.so functorch/functorch.so ||
die
+
+ hprefixify tools/setup_helpers/env.py
+}
+
+python_compile() {
+ PYTORCH_BUILD_VERSION=${PV} \
+ PYTORCH_BUILD_NUMBER=0 \
+ USE_SYSTEM_LIBS=ON \
+ CMAKE_BUILD_DIR="${BUILD_DIR}" \
+ distutils-r1_python_compile develop sdist
+}
+
+python_install() {
+ USE_SYSTEM_LIBS=ON distutils-r1_python_install
+}