From fa2d94b5e362c684da812d494463d965e601c18d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jul 2021 17:19:34 +0200 Subject: gnu: python-onnx: Rename to "onnx". * gnu/packages/machine-learning.scm (python-onnx): Rename to... (onnx): ... this, and change 'name' field accordingly. (python-onnx): New variable. * gnu/packages/patches/python-onnx-shared-libraries.patch: Rename to... * gnu/packages/patches/onnx-shared-libraries.patch: ... this. * gnu/packages/patches/python-onnx-use-system-googletest.patch: Rename to... * gnu/packages/patches/onnx-use-system-googletest.patch: ... this. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. --- gnu/local.mk | 4 +- gnu/packages/machine-learning.scm | 14 ++++-- gnu/packages/patches/onnx-shared-libraries.patch | 24 +++++++++ .../patches/onnx-use-system-googletest.patch | 57 ++++++++++++++++++++++ .../patches/python-onnx-shared-libraries.patch | 24 --------- .../python-onnx-use-system-googletest.patch | 57 ---------------------- 6 files changed, 93 insertions(+), 87 deletions(-) create mode 100644 gnu/packages/patches/onnx-shared-libraries.patch create mode 100644 gnu/packages/patches/onnx-use-system-googletest.patch delete mode 100644 gnu/packages/patches/python-onnx-shared-libraries.patch delete mode 100644 gnu/packages/patches/python-onnx-use-system-googletest.patch diff --git a/gnu/local.mk b/gnu/local.mk index 798560ca95..e6c03cbe55 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1512,6 +1512,8 @@ dist_patch_DATA = \ %D%/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch \ %D%/packages/patches/omake-fix-non-determinism.patch \ %D%/packages/patches/oneko-remove-nonfree-characters.patch \ + %D%/packages/patches/onnx-use-system-googletest.patch \ + %D%/packages/patches/onnx-shared-libraries.patch \ %D%/packages/patches/openbabel-fix-crash-on-nwchem-output.patch \ %D%/packages/patches/opencascade-oce-glibc-2.26.patch \ %D%/packages/patches/opencv-fix-build-of-grfmt_jpeg2000.cpp.patch \ @@ -1633,8 +1635,6 @@ dist_patch_DATA = \ %D%/packages/patches/python-memcached-syntax-warnings.patch \ %D%/packages/patches/python-mox3-python3.6-compat.patch \ %D%/packages/patches/python-testtools.patch \ - %D%/packages/patches/python-onnx-use-system-googletest.patch \ - %D%/packages/patches/python-onnx-shared-libraries.patch \ %D%/packages/patches/python-packaging-test-arch.patch \ %D%/packages/patches/python2-parameterized-docstring-test.patch \ %D%/packages/patches/python-paste-remove-timing-test.patch \ diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 1cea91977f..75faeb8eb8 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -581,16 +581,16 @@ (define (delete-ifdefs file) in terms of new algorithms.") (license license:gpl3+))) -(define-public python-onnx +(define-public onnx (package - (name "python-onnx") + (name "onnx") (version "1.9.0") (source (origin (method url-fetch) (uri (pypi-uri "onnx" version)) - (patches (search-patches "python-onnx-use-system-googletest.patch" - "python-onnx-shared-libraries.patch")) + (patches (search-patches "onnx-use-system-googletest.patch" + "onnx-shared-libraries.patch")) (sha256 (base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9")) (modules '((guix build utils))) @@ -658,6 +658,12 @@ (define args standard data types.") (license license:expat))) +(define-public python-onnx + ;; This used to be called "python-onnx" because it provided nothing but + ;; Python bindings. The package now provides shared libraries and C++ + ;; headers, hence the name change. + (deprecated-package "python-onnx" onnx)) + (define-public rxcpp (package (name "rxcpp") diff --git a/gnu/packages/patches/onnx-shared-libraries.patch b/gnu/packages/patches/onnx-shared-libraries.patch new file mode 100644 index 0000000000..00583b35da --- /dev/null +++ b/gnu/packages/patches/onnx-shared-libraries.patch @@ -0,0 +1,24 @@ +These linker options for the 'onnx_cpp2py_export.cpython-38-*-gnu.so' +(or similar) extension are meant to be used when building 'libonn.a', +a static archive. This patch adapts the link flags to linking with +'libonnx.so'. + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cede3073..52f846ed 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -475,11 +475,10 @@ if(BUILD_ONNX_PYTHON) + PRIVATE $) + else() + # Assume everything else is like gcc +- target_link_libraries(onnx_cpp2py_export +- PRIVATE "-Wl,--whole-archive" $ +- "-Wl,--no-whole-archive") ++ target_link_libraries(onnx_cpp2py_export PRIVATE onnx) + set_target_properties(onnx_cpp2py_export +- PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") ++ PROPERTIES LINK_FLAGS ++ "-Wl,-rpath=${CMAKE_INSTALL_PREFIX}/lib") + endif() + + target_link_libraries(onnx_cpp2py_export PRIVATE onnx) diff --git a/gnu/packages/patches/onnx-use-system-googletest.patch b/gnu/packages/patches/onnx-use-system-googletest.patch new file mode 100644 index 0000000000..5dfcbc6dc3 --- /dev/null +++ b/gnu/packages/patches/onnx-use-system-googletest.patch @@ -0,0 +1,57 @@ +ONNX will build googletest from a Git checkout. Patch CMake to use our +googletest package and enable tests by default. + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0aa9fda2..a573170c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -22,7 +22,7 @@ option(BUILD_ONNX_PYTHON "Build Python binaries" OFF) + 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_BUILD_TESTS "Build ONNX C++ APIs Tests" ON) + option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF) + option(ONNXIFI_ENABLE_EXT "Enable onnxifi extensions." OFF) + if(NOT DEFINED ONNX_ML) +@@ -82,8 +82,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + endif() + + if(ONNX_BUILD_TESTS) +- list(APPEND CMAKE_MODULE_PATH ${ONNX_ROOT}/cmake/external) +- include(googletest) ++ find_package(GTest REQUIRED) ++ if(NOT GTest_FOUND) ++ message(FATAL_ERROR "cannot find googletest") ++ endif() + endif() + + if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf)) +diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake +index e29a93ff..ae146390 100644 +--- a/cmake/unittest.cmake ++++ b/cmake/unittest.cmake +@@ -6,8 +6,8 @@ include(${ONNX_ROOT}/cmake/Utils.cmake) + + find_package(Threads) + +-set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES}) +-set(${ONNXIFI_TEST_DRIVER}_libs ${googletest_STATIC_LIBRARIES}) ++set(${UT_NAME}_libs ${GTEST_LIBRARIES}) ++set(${ONNXIFI_TEST_DRIVER}_libs ${GTEST_LIBRARIES}) + + list(APPEND ${UT_NAME}_libs onnx) + list(APPEND ${UT_NAME}_libs onnx_proto) +@@ -31,10 +31,10 @@ function(AddTest) + list(REMOVE_DUPLICATES _UT_SOURCES) + + add_executable(${_UT_TARGET} ${_UT_SOURCES}) +- add_dependencies(${_UT_TARGET} onnx onnx_proto googletest) ++ add_dependencies(${_UT_TARGET} onnx onnx_proto) + + target_include_directories(${_UT_TARGET} +- PUBLIC ${googletest_INCLUDE_DIRS} ++ PUBLIC ${GTEST_INCLUDE_DIRS} + ${ONNX_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIRS} + ${ONNX_ROOT} diff --git a/gnu/packages/patches/python-onnx-shared-libraries.patch b/gnu/packages/patches/python-onnx-shared-libraries.patch deleted file mode 100644 index 00583b35da..0000000000 --- a/gnu/packages/patches/python-onnx-shared-libraries.patch +++ /dev/null @@ -1,24 +0,0 @@ -These linker options for the 'onnx_cpp2py_export.cpython-38-*-gnu.so' -(or similar) extension are meant to be used when building 'libonn.a', -a static archive. This patch adapts the link flags to linking with -'libonnx.so'. - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index cede3073..52f846ed 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -475,11 +475,10 @@ if(BUILD_ONNX_PYTHON) - PRIVATE $) - else() - # Assume everything else is like gcc -- target_link_libraries(onnx_cpp2py_export -- PRIVATE "-Wl,--whole-archive" $ -- "-Wl,--no-whole-archive") -+ target_link_libraries(onnx_cpp2py_export PRIVATE onnx) - set_target_properties(onnx_cpp2py_export -- PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") -+ PROPERTIES LINK_FLAGS -+ "-Wl,-rpath=${CMAKE_INSTALL_PREFIX}/lib") - endif() - - target_link_libraries(onnx_cpp2py_export PRIVATE onnx) diff --git a/gnu/packages/patches/python-onnx-use-system-googletest.patch b/gnu/packages/patches/python-onnx-use-system-googletest.patch deleted file mode 100644 index 5dfcbc6dc3..0000000000 --- a/gnu/packages/patches/python-onnx-use-system-googletest.patch +++ /dev/null @@ -1,57 +0,0 @@ -ONNX will build googletest from a Git checkout. Patch CMake to use our -googletest package and enable tests by default. - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0aa9fda2..a573170c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -22,7 +22,7 @@ option(BUILD_ONNX_PYTHON "Build Python binaries" OFF) - 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_BUILD_TESTS "Build ONNX C++ APIs Tests" ON) - option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF) - option(ONNXIFI_ENABLE_EXT "Enable onnxifi extensions." OFF) - if(NOT DEFINED ONNX_ML) -@@ -82,8 +82,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") - endif() - - if(ONNX_BUILD_TESTS) -- list(APPEND CMAKE_MODULE_PATH ${ONNX_ROOT}/cmake/external) -- include(googletest) -+ find_package(GTest REQUIRED) -+ if(NOT GTest_FOUND) -+ message(FATAL_ERROR "cannot find googletest") -+ endif() - endif() - - if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf)) -diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake -index e29a93ff..ae146390 100644 ---- a/cmake/unittest.cmake -+++ b/cmake/unittest.cmake -@@ -6,8 +6,8 @@ include(${ONNX_ROOT}/cmake/Utils.cmake) - - find_package(Threads) - --set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES}) --set(${ONNXIFI_TEST_DRIVER}_libs ${googletest_STATIC_LIBRARIES}) -+set(${UT_NAME}_libs ${GTEST_LIBRARIES}) -+set(${ONNXIFI_TEST_DRIVER}_libs ${GTEST_LIBRARIES}) - - list(APPEND ${UT_NAME}_libs onnx) - list(APPEND ${UT_NAME}_libs onnx_proto) -@@ -31,10 +31,10 @@ function(AddTest) - list(REMOVE_DUPLICATES _UT_SOURCES) - - add_executable(${_UT_TARGET} ${_UT_SOURCES}) -- add_dependencies(${_UT_TARGET} onnx onnx_proto googletest) -+ add_dependencies(${_UT_TARGET} onnx onnx_proto) - - target_include_directories(${_UT_TARGET} -- PUBLIC ${googletest_INCLUDE_DIRS} -+ PUBLIC ${GTEST_INCLUDE_DIRS} - ${ONNX_INCLUDE_DIRS} - ${PROTOBUF_INCLUDE_DIRS} - ${ONNX_ROOT} -- cgit v1.2.3