git: 049df0e2b3e3 - main - misc/py-onnxruntime: Fix Python module

Yuri Victorovich <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.ports
Message-ID <6a75688e.277fa.456ec0e6__30295.8338333823$1786079403$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=049df0e2b3e31e87dc334eeb4816ad6863e8b8d3

commit 049df0e2b3e31e87dc334eeb4816ad6863e8b8d3
Author:     Yuri Victorovich <[email protected]>
AuthorDate: 2026-08-07 03:10:26 +0000
Commit:     Yuri Victorovich <[email protected]>
CommitDate: 2026-08-07 05:09:29 +0000

    misc/py-onnxruntime: Fix Python module
    
    It wasn't properly installed before.
---
 misc/py-onnxruntime/Makefile                       |  32 ++++--
 .../files/patch-cmake_onnxruntime__python.cmake    |  21 ++++
 misc/py-onnxruntime/pkg-plist                      | 121 ---------------------
 3 files changed, 46 insertions(+), 128 deletions(-)

diff --git a/misc/py-onnxruntime/Makefile b/misc/py-onnxruntime/Makefile
index 26de783fe7d7..5ced2db4c40b 100644
--- a/misc/py-onnxruntime/Makefile
+++ b/misc/py-onnxruntime/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	onnxruntime
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.27.0
+PORTREVISION=	1
 CATEGORIES=	misc # machine-learning
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
 DIST_SUBDIR=	${PORTNAME}
@@ -14,12 +15,22 @@ LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
 BUILD_DEPENDS=	cmake:devel/cmake-core \
-		${PYTHON_PKGNAMEPREFIX}packaging>=0:devel/py-packaging@${PY_FLAVOR}
+		${PYTHON_PKGNAMEPREFIX}packaging>=0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}setuptools>=0:devel/py-setuptools@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}wheel>=0:devel/py-wheel@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}numpy>=1.21.6:math/py-numpy@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}numpy>=1.21.6:math/py-numpy@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}packaging>=0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}protobuf>=4.25.8:devel/py-protobuf@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}flatbuffers>=0:devel/py-flatbuffers@${PY_FLAVOR}
 
 USES=		compiler:c++17-lang python
-USE_PYTHON=	pep517
+USE_PYTHON=	pep517 autoplist concurrent
+
+# Build using the official build.py script; wheel is left in ${WRKDIR}/build/Release/dist.
+PEP517_BUILD_DEPEND=
+PEP517_INSTALL_CMD=	${PYTHON_CMD} -m installer --destdir ${STAGEDIR} --prefix ${PREFIX} ${WRKDIR}/build/Release/dist/onnxruntime-${DISTVERSION}*.whl
 
-# Build using the official build.py script
 do-build:
 	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
 		${PYTHON_CMD} tools/ci_build/build.py \
@@ -29,12 +40,19 @@ do-build:
 		--skip_tests \
 		--skip_submodule_sync \
 		--allow_running_as_root \
+		--enable_pybind \
+		--build_wheel \
 		--cmake_extra_defines CMAKE_INSTALL_PREFIX=${PREFIX} \
-		--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF
+		--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
+		--cmake_extra_defines ONNXRUNTIME_NUMPY_INCLUDE_DIR=${PYTHONPREFIX_SITELIBDIR}/numpy/_core/include
 
-do-install:
-	cd ${WRKDIR}/build/Release && ${SETENV} ${MAKE_ENV} \
-		${MAKE_CMD} install DESTDIR=${STAGEDIR}
+# The upstream wheel build does not include the native pybind extension, so
+# install it alongside the pure-Python files and add it to the autoplist.
+post-install:
+	${INSTALL_DATA} ${WRKDIR}/build/Release/onnxruntime/capi/onnxruntime_pybind11_state.so \
+		${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/onnxruntime/capi/
+	@${ECHO_CMD} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/onnxruntime/capi/onnxruntime_pybind11_state.so \
+		>> ${_PYTHONPKGLIST}
 
 USE_GITHUB=	yes
 GH_ACCOUNT=	microsoft
diff --git a/misc/py-onnxruntime/files/patch-cmake_onnxruntime__python.cmake b/misc/py-onnxruntime/files/patch-cmake_onnxruntime__python.cmake
new file mode 100644
index 000000000000..b2faf03bca15
--- /dev/null
+++ b/misc/py-onnxruntime/files/patch-cmake_onnxruntime__python.cmake
@@ -0,0 +1,21 @@
+-- Provide a fallback Python::NumPy imported target for builds where CMake's
+-- FindPython does not detect NumPy 2.x headers (e.g. in poudriere). The
+-- include directory is passed via ONNXRUNTIME_NUMPY_INCLUDE_DIR in the Makefile.
+
+--- cmake/onnxruntime_python.cmake.orig	2026-08-06 23:27:52 UTC
++++ cmake/onnxruntime_python.cmake
+@@ -213,6 +213,14 @@ endif()
+   # onnxruntime_pybind11_state is a DLL
+   target_sources(onnxruntime_pybind11_state PRIVATE "${ONNXRUNTIME_ROOT}/core/dll/dllmain.cc")
+ endif()
++# FreeBSD: CMake's FindPython may not detect NumPy 2.x headers in poudriere,
++# so provide a fallback imported target with the include directory supplied by
++# the port's Makefile via ONNXRUNTIME_NUMPY_INCLUDE_DIR.
++if(NOT TARGET Python::NumPy)
++  add_library(Python::NumPy INTERFACE IMPORTED)
++  set_target_properties(Python::NumPy PROPERTIES
++    INTERFACE_INCLUDE_DIRECTORIES "${ONNXRUNTIME_NUMPY_INCLUDE_DIR}")
++endif()
+ target_link_libraries(onnxruntime_pybind11_state PRIVATE
+     onnxruntime_session
+     ${onnxruntime_libs}
diff --git a/misc/py-onnxruntime/pkg-plist b/misc/py-onnxruntime/pkg-plist
deleted file mode 100644
index 49428b44319c..000000000000
--- a/misc/py-onnxruntime/pkg-plist
+++ /dev/null
@@ -1,121 +0,0 @@
-include/onnxruntime/core/common/basic_types.h
-include/onnxruntime/core/common/code_location.h
-include/onnxruntime/core/common/common.h
-include/onnxruntime/core/common/const_pointer_container.h
-include/onnxruntime/core/common/denormal.h
-include/onnxruntime/core/common/eigen_common_wrapper.h
-include/onnxruntime/core/common/endian.h
-include/onnxruntime/core/common/exceptions.h
-include/onnxruntime/core/common/float16.h
-include/onnxruntime/core/common/float8.h
-include/onnxruntime/core/common/gpu_profiler_common.h
-include/onnxruntime/core/common/hash_combine.h
-include/onnxruntime/core/common/inlined_containers.h
-include/onnxruntime/core/common/inlined_containers_fwd.h
-include/onnxruntime/core/common/logging/capture.h
-include/onnxruntime/core/common/logging/isink.h
-include/onnxruntime/core/common/logging/logging.h
-include/onnxruntime/core/common/logging/macros.h
-include/onnxruntime/core/common/logging/severity.h
-include/onnxruntime/core/common/logging/sink_types.h
-include/onnxruntime/core/common/make_string.h
-include/onnxruntime/core/common/narrow.h
-include/onnxruntime/core/common/optional.h
-include/onnxruntime/core/common/parse_string.h
-include/onnxruntime/core/common/profiler_common.h
-include/onnxruntime/core/common/span_utils.h
-include/onnxruntime/core/common/spin_pause.h
-include/onnxruntime/core/common/status.h
-include/onnxruntime/core/common/string_helper.h
-include/onnxruntime/core/framework/alloc_kind.h
-include/onnxruntime/core/framework/allocator.h
-include/onnxruntime/core/framework/buffer_deleter.h
-include/onnxruntime/core/framework/customregistry.h
-include/onnxruntime/core/framework/data_types.h
-include/onnxruntime/core/framework/data_types_internal.h
-include/onnxruntime/core/framework/execution_provider.h
-include/onnxruntime/core/framework/float4.h
-include/onnxruntime/core/framework/framework_common.h
-include/onnxruntime/core/framework/framework_provider_common.h
-include/onnxruntime/core/framework/func_api.h
-include/onnxruntime/core/framework/int2.h
-include/onnxruntime/core/framework/int4.h
-include/onnxruntime/core/framework/kernel_def_builder.h
-include/onnxruntime/core/framework/kernel_registry.h
-include/onnxruntime/core/framework/op_kernel.h
-include/onnxruntime/core/framework/op_kernel_context.h
-include/onnxruntime/core/framework/op_kernel_info.h
-include/onnxruntime/core/framework/op_node_proto_helper.h
-include/onnxruntime/core/framework/ort_value.h
-include/onnxruntime/core/framework/ortdevice.h
-include/onnxruntime/core/framework/ortmemoryinfo.h
-include/onnxruntime/core/framework/provider_options.h
-include/onnxruntime/core/framework/provider_options_utils.h
-include/onnxruntime/core/framework/provider_shutdown.h
-include/onnxruntime/core/framework/resource_accountant.h
-include/onnxruntime/core/framework/run_options.h
-include/onnxruntime/core/framework/sparse_tensor.h
-include/onnxruntime/core/framework/stream_handles.h
-include/onnxruntime/core/framework/tensor.h
-include/onnxruntime/core/framework/tensor_shape.h
-include/onnxruntime/core/framework/to_tensor_proto_element_type.h
-include/onnxruntime/core/graph/basic_types.h
-include/onnxruntime/core/graph/constants.h
-include/onnxruntime/core/graph/function.h
-include/onnxruntime/core/graph/graph.h
-include/onnxruntime/core/graph/graph_nodes.h
-include/onnxruntime/core/graph/graph_viewer.h
-include/onnxruntime/core/graph/indexed_sub_graph.h
-include/onnxruntime/core/graph/model_saving_options.h
-include/onnxruntime/core/graph/node_arg.h
-include/onnxruntime/core/graph/onnx_protobuf.h
-include/onnxruntime/core/graph/schema_registry.h
-include/onnxruntime/core/optimizer/graph_transformer.h
-include/onnxruntime/core/optimizer/graph_transformer_config.h
-include/onnxruntime/core/optimizer/graph_transformer_level.h
-include/onnxruntime/core/optimizer/graph_transformer_utils.h
-include/onnxruntime/core/optimizer/rewrite_rule.h
-include/onnxruntime/core/optimizer/rule_based_graph_transformer.h
-include/onnxruntime/core/providers/custom_op_context.h
-include/onnxruntime/core/providers/resource.h
-include/onnxruntime/core/session/environment.h
-include/onnxruntime/core/session/experimental_onnxruntime_cxx_api.h
-include/onnxruntime/core/session/experimental_onnxruntime_cxx_inline.h
-include/onnxruntime/core/session/onnxruntime_c_api.h
-include/onnxruntime/core/session/onnxruntime_cxx_api.h
-include/onnxruntime/core/session/onnxruntime_cxx_inline.h
-include/onnxruntime/core/session/onnxruntime_env_config_keys.h
-include/onnxruntime/core/session/onnxruntime_ep_c_api.h
-include/onnxruntime/core/session/onnxruntime_ep_device_ep_metadata_keys.h
-include/onnxruntime/core/session/onnxruntime_float16.h
-include/onnxruntime/core/session/onnxruntime_lite_custom_op.h
-include/onnxruntime/core/session/onnxruntime_run_options_config_keys.h
-include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h
-include/onnxruntime/core/session/snippets.dox
-include/onnxruntime/cpu_provider_factory.h
-include/onnxruntime/onnxruntime_c_api.h
-include/onnxruntime/onnxruntime_cxx_api.h
-include/onnxruntime/onnxruntime_cxx_inline.h
-include/onnxruntime/onnxruntime_env_config_keys.h
-include/onnxruntime/onnxruntime_ep_c_api.h
-include/onnxruntime/onnxruntime_ep_device_ep_metadata_keys.h
-include/onnxruntime/onnxruntime_float16.h
-include/onnxruntime/onnxruntime_lite_custom_op.h
-include/onnxruntime/onnxruntime_run_options_config_keys.h
-include/onnxruntime/onnxruntime_session_options_config_keys.h
-lib/libonnxruntime_common.a
-lib/libonnxruntime_flatbuffers.a
-lib/libonnxruntime_framework.a
-lib/libonnxruntime_graph.a
-lib/libonnxruntime_lora.a
-lib/libonnxruntime_mlas.a
-lib/libonnxruntime_optimizer.a
-lib/libonnxruntime_providers.a
-lib/libonnxruntime_providers_shared.so
-lib/libonnxruntime_session.a
-lib/libonnxruntime_util.a
-lib/cmake/onnxruntime/onnxruntimeConfig.cmake
-lib/cmake/onnxruntime/onnxruntimeConfigVersion.cmake
-lib/cmake/onnxruntime/onnxruntimeTargets-release.cmake
-lib/cmake/onnxruntime/onnxruntimeTargets.cmake
-libdata/pkgconfig/libonnxruntime.pc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.