gnu: Add liblantern.

* gnu/packages/machine-learning.scm (liblantern): New variable.
This commit is contained in:
Ricardo Wurmus 2022-02-11 15:40:29 +01:00
parent 7b676317b3
commit 7146e553b9
No known key found for this signature in database
GPG key ID: 197A5888235FACAC

View file

@ -3113,3 +3113,65 @@ (define-public python-hmmlearn
"Hmmlearn is a set of algorithms for unsupervised learning and inference
of Hidden Markov Models.")
(license license:bsd-3)))
;; Keep this in sync with the r-torch package.
(define-public liblantern
(package
(name "liblantern")
(version "0.6.0")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/mlverse/torch")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32 "1gabwic46m4m7qld1yi4brw05n9jx58ri3y0pi6jf9jndfi1qnfp"))))
(build-system cmake-build-system)
(arguments
(list
#:tests? #false ;no test target
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'chdir
(lambda _ (chdir "lantern")))
(add-after 'chdir 'do-not-download-binaries
(lambda* (#:key inputs #:allow-other-keys)
(substitute* "CMakeLists.txt"
(("find_package\\(Torch.*") "set(TORCH_CXX_FLAGS \"-ltorch\")\n")
(("retrieve_lib\\(.*") ""))
(setenv "LIBRARY_PATH"
(string-append
(search-input-directory
inputs "/lib/python3.9/site-packages/torch/lib")
":" (or (getenv "LIBRARY_PATH") "")))
(setenv "CPLUS_INCLUDE_PATH"
(string-append
(search-input-directory
inputs "lib/python3.9/site-packages/torch/include/torch/csrc/api/include/")
":"
(search-input-directory
inputs "lib/python3.9/site-packages/torch/include/")
":"
(or (getenv "CPLUS_INCLUDE_PATH") "")))
(setenv "C_INCLUDE_PATH"
(string-append
(search-input-directory
inputs "lib/python3.9/site-packages/torch/include/")
":"
(or (getenv "C_INCLUDE_PATH") "")))))
(replace 'install
(lambda _
(install-file
"../build/liblantern.so"
(string-append #$output "/lib"))
(copy-recursively
"../lantern/include"
(string-append #$output "/include")))))))
(inputs (list python-pytorch-for-r-torch))
(home-page "https://github.com/mlverse/torch/")
(synopsis "C API to libtorch")
(description
"Lantern provides a C API to the libtorch machine learning library.")
(license license:expat)))