From 1b632d409bf5c15ce376c3616c8d63a530b4ce01 Mon Sep 17 00:00:00 2001 From: Pavel Sobolev Date: Sat, 11 Jul 2026 22:58:51 +0300 Subject: [PATCH] sci-libs/onnxruntime: add 1.27.1 Signed-off-by: Pavel Sobolev --- sci-libs/onnxruntime/Manifest | 1 + .../onnxruntime/onnxruntime-1.27.1.ebuild | 181 ++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 sci-libs/onnxruntime/onnxruntime-1.27.1.ebuild diff --git a/sci-libs/onnxruntime/Manifest b/sci-libs/onnxruntime/Manifest index a75478f1a9..a888dc093b 100644 --- a/sci-libs/onnxruntime/Manifest +++ b/sci-libs/onnxruntime/Manifest @@ -1,3 +1,4 @@ DIST eigen-3.4.0_p20250216.tar.bz2 2272941 BLAKE2B c86764a5c31b978d09f9f8f458a982fb16c2cdfd053e0c7a371fbe5b9c64bead42c25fb7d4cb795eb5ee7ff1800bb51fac6783ad0881dd69dee5d463ccd213e3 SHA512 3c9fab41bde1ee4b8f5ba21c991a75cc73e104cdb48f3377b5fc51afae8cbb5e891c39e4fd998c5263178a8962b09d9d907b9d125dfddc50bc2ec5171917d6b8 DIST onnxruntime-1.26.0.tar.gz 285128576 BLAKE2B 825f73cf8aa5ecb185f7e77e825e78906666ddc6f194f4034e5443900e9d8e90b20173b0ba33c37b80650658e589078dad6f7c6c7c86ff5247bc797f4d4aa952 SHA512 14d629a14eb2161178c6babe49ed8a3adb15e8c6d26adc4c975261f9b5d43674e8a85bc4dbeb05a87917291d44b056140a1ac5a1c70ed80d92cb3f38cc670ebd DIST onnxruntime-1.27.0.tar.gz 285714570 BLAKE2B 2c25873f92ee144a567b5fdf745327c8f5c7c42010565db1d26856115dc2345c6b3304e235a17990e30278e30c4986b5d078688f64006f64f74c25927ceb75f6 SHA512 578ccf5321233bc65252b0bbfceaee183abc06175039fd6e0d044af0a4ae43b424c6f71c97b8e5bc6adb9992982d79e397eb4884f0370b4083b3b37d539a404d +DIST onnxruntime-1.27.1.tar.gz 285765941 BLAKE2B 5e8afa1f389e89a24611241ad6fae3b855b52c8ec6996903ded0e3a4029defc23779b6d182d94beb7f467fb760b8bfc1f9c9e687fa97857b5316117ec935a130 SHA512 2b21f00fdfe2cc971801b85c7ff4a939a58250d849ef276dff77eecf973e3cde505ceb68b00f0f8a30ab3c53070b5e648ff61c1d04669ac61f62e1db83b6aaca diff --git a/sci-libs/onnxruntime/onnxruntime-1.27.1.ebuild b/sci-libs/onnxruntime/onnxruntime-1.27.1.ebuild new file mode 100644 index 0000000000..4c85013de1 --- /dev/null +++ b/sci-libs/onnxruntime/onnxruntime-1.27.1.ebuild @@ -0,0 +1,181 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{12..14} ) + +inherit cmake edo flag-o-matic python-r1 + +EIGEN_COMMIT="1d8b82b0740839c0de7f1242a3585e3390ff5f33" + +DESCRIPTION="Cross-platform, high performance ML inferencing and training accelerator" +HOMEPAGE=" + https://onnxruntime.ai + https://github.com/microsoft/onnxruntime +" +SRC_URI=" + https://github.com/microsoft/onnxruntime/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz + https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_COMMIT}/eigen-${EIGEN_COMMIT}.tar.bz2 -> + eigen-3.4.0_p20250216.tar.bz2 +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" +IUSE="python test" +REQUIRED_USE="${PYTHON_REQUIRED_USE}" +RESTRICT="!test? ( test )" + +RDEPEND=" + dev-cpp/abseil-cpp:= + dev-libs/cpuinfo + dev-libs/protobuf:= + dev-libs/re2:= + sci-ml/onnx[disableStaticReg] + + python? ( + ${PYTHON_DEPS} + dev-python/coloredlogs[${PYTHON_USEDEP}] + dev-python/flatbuffers[${PYTHON_USEDEP}] + >=dev-python/numpy-2[${PYTHON_USEDEP}] + dev-python/packaging[${PYTHON_USEDEP}] + dev-python/protobuf[${PYTHON_USEDEP}] + dev-python/sympy[${PYTHON_USEDEP}] + sci-ml/onnx[${PYTHON_USEDEP}] + ) +" +DEPEND=" + ${RDEPEND} + dev-cpp/ms-gsl + dev-cpp/nlohmann_json + dev-cpp/safeint + dev-libs/boost + dev-libs/date + dev-libs/flatbuffers + + python? ( + dev-python/pybind11[${PYTHON_USEDEP}] + sci-libs/dlpack + ) +" +BDEPEND=" + ${PYTHON_DEPS} + + test? ( + dev-cpp/gtest + $(python_gen_any_dep 'sci-ml/onnx[${PYTHON_USEDEP}]') + + python? ( dev-python/pytest[${PYTHON_USEDEP}] ) + ) +" + +PATCHES=( + "${FILESDIR}/${PN}-1.22.2-relax-the-dependency-on-flatbuffers.patch" + "${FILESDIR}/${PN}-1.24.4-no-werror.patch" + "${FILESDIR}/${PN}-1.26.0-r1-prevent-generation-of-PIE.patch" + "${FILESDIR}/${PN}-1.27.0-use-system-libraries.patch" +) + +CMAKE_USE_DIR="${S}/cmake" + +# The `$(python_get_sitedir)/onnx/onnx-ml.proto` file is used during tests +python_check_deps() { + ! use test && return 0 + python_has_version "sci-ml/onnx[${PYTHON_USEDEP}]" +} + +src_configure() { + # Python is used at build time unconditionally + python_setup + + local mycmakeargs=( + -Donnxruntime_BUILD_SHARED_LIB=on + + -Donnxruntime_BUILD_UNIT_TESTS=$(usex test) + -Donnxruntime_ENABLE_PYTHON=$(usex python) + + # This is required until a newer version of Eigen3 comes out + -DFETCHCONTENT_SOURCE_DIR_EIGEN3="${WORKDIR}/eigen-${EIGEN_COMMIT}" + + # This makes it possible for `find_path` to find the `onnx-ml.proto` file + -DCMAKE_INCLUDE_PATH="$(python_get_sitedir)" + + -Wno-dev + ) + + append-ldflags -Wl,-z,noexecstack + + if use python; then + python_foreach_impl cmake_src_configure + else + cmake_src_configure + fi +} + +src_compile() { + if use python; then + python_foreach_impl cmake_src_compile + else + cmake_src_compile + fi +} + +# Adapted from `run_onnxruntime_tests` in `tools/ci_build/build.py` +python_test() { + cd "${BUILD_DIR}" || die + epytest --pyargs \ + onnxruntime_test_python.py \ + onnxruntime_test_python_backend.py \ + onnxruntime_test_python_mlops.py \ + onnxruntime_test_python_sparse_matmul.py +} + +src_test() { + # https://bugs.gentoo.org/975584 + local GTEST_SKIP_TESTS=( + "ActivationOpNoInfTest.Softsign" + "NhwcTransformerTests.ConvFloat_UsesNhwcOnlyWithKleidi" + "Random.MultinomialDefaultDType" + "Random.MultinomialGoodCase" + "SamplingTest.Gpt2Sampling_CPU" + "SignalOpsTest.DFT17_2D_complex_onesided_inverse" + "SignalOpsTest.DFT17_IRFFT_naive" + "SignalOpsTest.DFT17_IRFFT_radix2" + "SignalOpsTest.DFT17_RFFT_IRFFT_roundtrip" + "SignalOpsTest.DFT20_2D_complex_onesided_inverse" + "SignalOpsTest.DFT20_IRFFT_naive" + "SignalOpsTest.DFT20_IRFFT_radix2" + "SignalOpsTest.DFT20_RFFT_IRFFT_roundtrip" + ) + local -x GTEST_FILTER="*:-$(IFS=':'; echo "${GTEST_SKIP_TESTS[*]}")" + + if use python; then + python_foreach_impl cmake_src_test + python_foreach_impl python_test + else + cmake_src_test + fi +} + +# There is some custom logic in `setup.py` +python_install() { + cd "${BUILD_DIR}" || die + edo "${EPYTHON}" ../setup.py install \ + --prefix="${EPREFIX}/usr" \ + --root="${D}" + + rm -rf "${D}/$(python_get_sitedir)"/*.egg-info || die + python_optimize +} + +src_install() { + if use python; then + python_foreach_impl cmake_src_install + python_foreach_impl python_install + else + cmake_src_install + fi + + einstalldocs +}