mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 13:58:15 -05:00
gnu: python-onnx: Install libonnx.so and libonnx_proto.so.
* gnu/packages/patches/python-onnx-shared-libraries.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/machine-learning.scm (python-onnx)[source]: Use it. [arguments]: New field.
This commit is contained in:
parent
bb5b6b09dc
commit
2b55f914c3
3 changed files with 63 additions and 1 deletions
|
@ -1634,6 +1634,7 @@ dist_patch_DATA = \
|
||||||
%D%/packages/patches/python-mox3-python3.6-compat.patch \
|
%D%/packages/patches/python-mox3-python3.6-compat.patch \
|
||||||
%D%/packages/patches/python-testtools.patch \
|
%D%/packages/patches/python-testtools.patch \
|
||||||
%D%/packages/patches/python-onnx-use-system-googletest.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/python-packaging-test-arch.patch \
|
||||||
%D%/packages/patches/python2-parameterized-docstring-test.patch \
|
%D%/packages/patches/python2-parameterized-docstring-test.patch \
|
||||||
%D%/packages/patches/python-paste-remove-timing-test.patch \
|
%D%/packages/patches/python-paste-remove-timing-test.patch \
|
||||||
|
|
|
@ -589,12 +589,49 @@ (define-public python-onnx
|
||||||
(origin
|
(origin
|
||||||
(method url-fetch)
|
(method url-fetch)
|
||||||
(uri (pypi-uri "onnx" version))
|
(uri (pypi-uri "onnx" version))
|
||||||
(patches (search-patches "python-onnx-use-system-googletest.patch"))
|
(patches (search-patches "python-onnx-use-system-googletest.patch"
|
||||||
|
"python-onnx-shared-libraries.patch"))
|
||||||
(sha256
|
(sha256
|
||||||
(base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9"))
|
(base32 "0yjv2axz2vc2ysniwislsp53fsb8f61y1warrr2ppn2d9ijml1d9"))
|
||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet '(delete-file-recursively "third_party"))))
|
(snippet '(delete-file-recursively "third_party"))))
|
||||||
(build-system python-build-system)
|
(build-system python-build-system)
|
||||||
|
(arguments
|
||||||
|
'(#:phases (modify-phases %standard-phases
|
||||||
|
(add-before 'build 'pass-cmake-arguments
|
||||||
|
(lambda* (#:key outputs #:allow-other-keys)
|
||||||
|
;; Pass options to the CMake-based build process.
|
||||||
|
(define out
|
||||||
|
(assoc-ref outputs "out"))
|
||||||
|
|
||||||
|
(define args
|
||||||
|
;; Copy arguments from 'cmake-build-system', plus ask
|
||||||
|
;; for shared libraries.
|
||||||
|
(list "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||||
|
(string-append "-DCMAKE_INSTALL_PREFIX=" out)
|
||||||
|
"-DCMAKE_INSTALL_LIBDIR=lib"
|
||||||
|
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
|
||||||
|
(string-append "-DCMAKE_INSTALL_RPATH=" out
|
||||||
|
"/lib")
|
||||||
|
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||||
|
|
||||||
|
"-DBUILD_SHARED_LIBS=ON"))
|
||||||
|
|
||||||
|
;; This environment variable is honored by 'setup.py',
|
||||||
|
;; which passes it down to 'cmake'.
|
||||||
|
(setenv "CMAKE_ARGS" (string-join args))
|
||||||
|
|
||||||
|
;; This one is honored by 'setup.py' and passed to 'make
|
||||||
|
;; -j'.
|
||||||
|
(setenv "MAX_JOBS"
|
||||||
|
(number->string (parallel-job-count)))))
|
||||||
|
(add-after 'install 'install-from-cmake
|
||||||
|
(lambda _
|
||||||
|
;; Run "make install" in the build tree 'setup.py'
|
||||||
|
;; created for CMake so that libonnx.so,
|
||||||
|
;; libonnx_proto.so, etc. are installed.
|
||||||
|
(invoke "make" "install"
|
||||||
|
"-C" ".setuptools-cmake-build"))))))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(("cmake" ,cmake)
|
`(("cmake" ,cmake)
|
||||||
("googletest" ,googletest)
|
("googletest" ,googletest)
|
||||||
|
|
24
gnu/packages/patches/python-onnx-shared-libraries.patch
Normal file
24
gnu/packages/patches/python-onnx-shared-libraries.patch
Normal file
|
@ -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 $<TARGET_OBJECTS:onnx>)
|
||||||
|
else()
|
||||||
|
# Assume everything else is like gcc
|
||||||
|
- target_link_libraries(onnx_cpp2py_export
|
||||||
|
- PRIVATE "-Wl,--whole-archive" $<TARGET_FILE:onnx>
|
||||||
|
- "-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)
|
Loading…
Reference in a new issue