misc/py-onnx: Link with bundled protobuf-22.3 to prevent run-time failures

This commit is contained in:
Yuri Victorovich 2024-04-20 19:59:18 -07:00
parent 21051e9e43
commit a78b560136
3 changed files with 37 additions and 7 deletions

View file

@ -1,8 +1,16 @@
PORTNAME= onnx
DISTVERSION= 1.16.0
PORTREVISION= 1
CATEGORIES= misc # machine-learning
MASTER_SITES= PYPI
MASTER_SITES= PYPI \
https://github.com/abseil/abseil-cpp/archive/refs/tags/:abseil \
https://github.com/protocolbuffers/protobuf/releases/download/v22.3/:protobuf # use downloaded protobuf-22.3
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
DISTFILES= ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX} \
20230125.3.tar.gz:abseil \
protobuf-22.3.tar.gz:protobuf # use downloaded protobuf-22.3
DIST_SUBDIR= onnx
EXTRACT_ONLY= ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}
MAINTAINER= yuri@FreeBSD.org
COMMENT= Open Neural Network eXchange
@ -18,8 +26,8 @@ BUILD_DEPENDS= bash:shells/bash \
${PYTHON_PKGNAMEPREFIX}pytest-runner>=0:devel/py-pytest-runner@${PY_FLAVOR} \
${PY_SETUPTOOLS} \
${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR}
LIB_DEPENDS= libabsl_base.so:devel/abseil \
libprotobuf.so:devel/protobuf
#LIB_DEPENDS= libabsl_base.so:devel/abseil \
libprotobuf.so:devel/protobuf # disable packaged protobuf
RUN_DEPENDS= ${PYNUMPY} \
${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}typing-extensions>=3.6.2.1:devel/py-typing-extensions@${PY_FLAVOR}
@ -32,11 +40,21 @@ CXXFLAGS+= -Dstat64=stat
SHEBANG_FILES= tools/protoc-gen-mypy.sh.in
CONFLICTS_BUILD= protobuf # use downloaded protobuf-22.3
TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
TEST_WRKSRC= ${WRKSRC}/onnx/test
BINARY_ALIAS= python=${PYTHON_CMD}
post-patch: # replace protobuf-24+ with protobuf-lite-22.3
@${REINPLACE_CMD} \
-e ' \
s|set(ProtobufURL https://github.com/protocolbuffers/protobuf/releases/download/v22.3/|set(ProtobufURL file://${DISTDIR}/${DIST_SUBDIR}/|; \
s|set(AbseilURL https://github.com/abseil/abseil-cpp/archive/refs/tags/|set(AbseilURL file://${DISTDIR}/${DIST_SUBDIR}/| \
' \
${WRKSRC}/CMakeLists.txt
post-install:
@${STRIP_CMD} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/onnx/onnx_cpp2py_export*.so

View file

@ -1,3 +1,7 @@
TIMESTAMP = 1713580433
SHA256 (onnx-1.16.0.tar.gz) = 237c6987c6c59d9f44b6136f5819af79574f8d96a760a1fa843bede11f3822f7
SIZE (onnx-1.16.0.tar.gz) = 12303017
TIMESTAMP = 1713648416
SHA256 (onnx/onnx-1.16.0.tar.gz) = 237c6987c6c59d9f44b6136f5819af79574f8d96a760a1fa843bede11f3822f7
SIZE (onnx/onnx-1.16.0.tar.gz) = 12303017
SHA256 (onnx/20230125.3.tar.gz) = 5366d7e7fa7ba0d915014d387b66d0d002c03236448e1ba9ef98122c13b35c36
SIZE (onnx/20230125.3.tar.gz) = 2119655
SHA256 (onnx/protobuf-22.3.tar.gz) = 4101e11ef41afa91cac1bd95483cb781626781ae1a331501ed8379f2d82ca9bc
SIZE (onnx/protobuf-22.3.tar.gz) = 4919899

View file

@ -1,6 +1,8 @@
- use downloaded protobuf-22.3
--- CMakeLists.txt.orig 2024-03-05 00:46:58 UTC
+++ CMakeLists.txt
@@ -19,7 +19,7 @@ option(ONNX_USE_PROTOBUF_SHARED_LIBS "Build ONNX using
@@ -19,12 +19,12 @@ option(ONNX_USE_PROTOBUF_SHARED_LIBS "Build ONNX using
option(ONNX_BUILD_BENCHMARKS "Build ONNX micro-benchmarks" OFF)
option(ONNX_USE_PROTOBUF_SHARED_LIBS "Build ONNX using protobuf shared library. Sets PROTOBUF_USE_DLLS CMAKE Flag and Protobuf_USE_STATIC_LIBS. " OFF)
@ -9,3 +11,9 @@
option(ONNX_GEN_PB_TYPE_STUBS "Generate protobuf python type stubs" ON)
option(ONNX_WERROR "Build with Werror" OFF)
option(ONNX_COVERAGE "Build with coverage instrumentation" OFF)
option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF)
-option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
+option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." ON) # workaround for the failure, see https://github.com/onnx/optimizer/issues/38#issuecomment-817058821
option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
option(ONNX_DISABLE_STATIC_REGISTRATION "Disable static registration for onnx operator schemas." OFF)
option(ONNX_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)