[new-package] onnx 1.17.0

This commit is contained in:
مهدي شينون (Mehdi Chinoune) 2025-02-06 17:39:30 +01:00
parent 7f3c696547
commit b5c55012cc
2 changed files with 155 additions and 0 deletions

View File

@ -0,0 +1,58 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -582,7 +582,7 @@
# whole-archive linker option not available on AIX
target_sources(onnx_cpp2py_export
PRIVATE $<TARGET_OBJECTS:onnx>)
- else()
+ elseif(NOT MINGW)
# Assume everything else is like gcc
target_link_libraries(onnx_cpp2py_export
PRIVATE "-Wl,--whole-archive" $<TARGET_FILE:onnx>
@@ -598,8 +598,11 @@
target_link_libraries(onnx_cpp2py_export PRIVATE onnx)
- if(MSVC)
+ if(WIN32)
target_link_libraries(onnx_cpp2py_export PRIVATE ${PYTHON_LIBRARIES})
+ endif()
+
+ if(MSVC)
target_compile_options(onnx_cpp2py_export
PRIVATE /MP
/wd4244 # 'argument': conversion from 'google::
@@ -746,7 +749,10 @@
install(TARGETS
onnx onnx_proto
- EXPORT ONNXTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ EXPORT ONNXTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(ONNX_BUILD_TESTS)
include(${ONNX_ROOT}/cmake/unittest.cmake)
--- a/cmake/ONNXConfig.cmake.in
+++ b/cmake/ONNXConfig.cmake.in
@@ -6,8 +6,6 @@
# library version information
set(ONNX_VERSION "@ONNX_VERSION@")
-list(APPEND CMAKE_PREFIX_PATH "@PROTOBUF_DIR@")
-set(Protobuf_INCLUDE_DIR "@PROTOBUF_INCLUDE_DIR@")
find_package(Protobuf REQUIRED)
# import targets
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,7 @@
TOP_DIR = os.path.realpath(os.path.dirname(__file__))
CMAKE_BUILD_DIR = os.path.join(TOP_DIR, ".setuptools-cmake-build")
-WINDOWS = os.name == "nt"
+WINDOWS = os.name == "nt" and 'MSC' in sys.version
CMAKE = shutil.which("cmake3") or shutil.which("cmake")

97
mingw-w64-onnx/PKGBUILD Normal file
View File

@ -0,0 +1,97 @@
# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>
_realname=onnx
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.17.0
pkgrel=1
pkgdesc="Open standard for machine learning interoperability. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://www.onnx.ai'
msys2_repository_url="https://github.com/onnx/onnx"
license=('spdx:Apache-2.0')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-protobuf"
"${MINGW_PACKAGE_PREFIX}-pybind11"
"${MINGW_PACKAGE_PREFIX}-python-build"
"${MINGW_PACKAGE_PREFIX}-python-installer"
"${MINGW_PACKAGE_PREFIX}-python-setuptools"
"${MINGW_PACKAGE_PREFIX}-python-numpy"
"${MINGW_PACKAGE_PREFIX}-python-protobuf")
source=("https://github.com/onnx/onnx/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
"001-fix-build-on-mingw-w64.patch")
sha256sums=('8d5e983c36037003615e5a02d36b18fc286541bf52de1a78f6cf9f32005a820e'
'33ae2b4039973e3b736757cd5fa3e683dc76a0b1e76d45817a1b7d1d8e390e62')
prepare() {
cd ${_realname}-${pkgver}
patch -p1 -i "${srcdir}"/001-fix-build-on-mingw-w64.patch
}
build() {
rm -rf "python-build-${MSYSTEM}"
cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
declare -a _cmake_args
if check_option "debug" "n"; then
_cmake_args+=("-DCMAKE_BUILD_TYPE=Release")
else
_cmake_args+=("-DCMAKE_BUILD_TYPE=Debug")
fi
_cmake_args+=(
"-Wno-dev"
"-GNinja"
"-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX}"
"-DBUILD_SHARED_LIBS=ON"
"-DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
)
MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
ONNX_BUILD_TESTS=0 \
CMAKE_ARGS="${_cmake_args[@]}" \
python -m build --wheel --skip-dependency-check --no-isolation
}
package_onnx() {
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-protobuf")
DESTDIR="${pkgdir}" cmake --install python-build-${MSYSTEM}/.setuptools-cmake-build
install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" \
"${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
package_python-onnx() {
depends=("${MINGW_PACKAGE_PREFIX}-python"
"${MINGW_PACKAGE_PREFIX}-python-protobuf"
"${MINGW_PACKAGE_PREFIX}-python-numpy"
"${MINGW_PACKAGE_PREFIX}-onnx"
"${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-protobuf")
options=(!strip)
cd "${srcdir}/python-build-${MSYSTEM}"
MSYS2_ARG_CONV_EXCL="--prefix=" \
${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
--destdir="${pkgdir}" dist/*.whl
install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
# template start; name=mingw-w64-splitpkg-wrappers; version=1.0;
# vim: set ft=bash :
# generate wrappers
for _name in "${pkgname[@]}"; do
_short="package_${_name#${MINGW_PACKAGE_PREFIX}-}"
_func="$(declare -f "${_short}")"
eval "${_func/#${_short}/package_${_name}}"
done
# template end;