From 9e644d979d3a1b106ea52f9e8ca6ebb597b765a8 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 28 Dec 2021 14:14:11 +0100 Subject: gnu: tensorflow: Install C headers. * gnu/packages/machine-learning.scm (tensorflow)[arguments]: Add build phase 'patch-cmake-file-to-install-c-headers; move setting of LDFLAGS from 'build-pip-package to 'unpack-third-party-sources; move 'build-pip-package after 'install phase. [source]: Add patch. * gnu/packages/patches/tensorflow-c-api-fix.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/packages/machine-learning.scm | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'gnu/packages/machine-learning.scm') diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 8569ddd724..01c245bd5d 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -1766,7 +1766,9 @@ Python.") (file-name (string-append "tensorflow-" version "-checkout")) (sha256 (base32 - "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa")))) + "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa")) + (patches + (search-patches "tensorflow-c-api-fix.patch")))) (build-system cmake-build-system) (arguments `(#:tests? #f ; no "check" target @@ -1949,7 +1951,7 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " ;; This directory is a dependency of many targets. (mkdir-p "protobuf"))) (add-after 'configure 'unpack-third-party-sources - (lambda* (#:key inputs #:allow-other-keys) + (lambda* (#:key inputs outputs #:allow-other-keys) ;; This is needed to configure bundled packages properly. (setenv "CONFIG_SHELL" (which "bash")) (for-each @@ -1987,7 +1989,11 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " "re2")) (rename-file "../build/cub/src/cub/cub-1.8.0/" - "../build/cub/src/cub/cub/"))) + "../build/cub/src/cub/cub/") + + (setenv "LDFLAGS" + (string-append "-Wl,-rpath=" + (assoc-ref outputs "out") "/lib")))) (add-after 'unpack 'fix-python-build (lambda* (#:key inputs outputs #:allow-other-keys) (mkdir-p "protobuf-src") @@ -2023,11 +2029,21 @@ set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " COMPILE_FLAGS ${target_compile_flags} \ INSTALL_RPATH_USE_LINK_PATH TRUE \ INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))))) - (add-after 'build 'build-pip-package + (add-after 'unpack 'patch-cmake-file-to-install-c-headers + (lambda _ + (substitute* "tensorflow/contrib/cmake/tf_c.cmake" + (("if\\(tensorflow_BUILD_PYTHON_BINDINGS" m) + (string-append + "install(DIRECTORY ${tensorflow_source_dir}/tensorflow/c/ \ +DESTINATION include/tensorflow/c FILES_MATCHING PATTERN \"*.h\")\n" m))))) + (add-after 'build 'build-c-bindings + (lambda* (#:key outputs parallel-build? #:allow-other-keys) + (invoke "make" "-j" (if parallel-build? + (number->string (parallel-job-count)) + "1") + "tf_c"))) + (add-after 'install 'build-pip-package (lambda* (#:key outputs parallel-build? #:allow-other-keys) - (setenv "LDFLAGS" - (string-append "-Wl,-rpath=" - (assoc-ref outputs "out") "/lib")) (invoke "make" "-j" (if parallel-build? (number->string (parallel-job-count)) "1") -- cgit v1.2.3