@@ 3206,12 3206,16 @@ Python.")
(base32
"07f4x4g3kwhfjz7iadhqrv97zmw0blacixvca1gdqkqqi7aipxis"))))
(build-system cmake-build-system)
+ (outputs (list "out" "python"))
(arguments
(list
#:build-type "Release"
+ #:imported-modules (append %cmake-build-system-modules
+ %pyproject-build-system-modules)
#:modules '((ice-9 match)
(guix build utils)
- (guix build cmake-build-system))
+ (guix build cmake-build-system)
+ ((guix build pyproject-build-system) #:prefix py:))
#:configure-flags
#~(list
;; "-DTFLITE_KERNEL_TEST=ON" ; TODO: build tests
@@ 3328,17 3332,46 @@ find_library(ML_DTYPES_LIBRARIES
(lambda _
(invoke "cmake" "--build" "." "--target" "benchmark_model"
"-j" (number->string (parallel-job-count)))))
-
+ (add-after 'build-benchmark-model 'build-python
+ (lambda* (#:key configure-flags #:allow-other-keys)
+ (let ((script (string-append "../lite/tools/pip_package/"
+ "build_pip_package_with_cmake.sh")))
+ (substitute* script
+ (("\"\\$\\{TENSORFLOW_LITE_DIR\\}\"" all)
+ (string-append "${CMAKE_ADDITIONAL_CONFIGURE_FLAGS} "
+ all)))
+ (setenv "BUILD_NUM_JOBS" (number->string (parallel-job-count)))
+ (setenv "CMAKE_ADDITIONAL_CONFIGURE_FLAGS"
+ (string-join configure-flags " "))
+ (invoke "sh" script))))
(add-after 'install 'install-extra
(lambda _
(install-file "../build/c/libtensorflowlite_c.so"
(string-append #$output "/lib"))
(install-file "../build/tools/benchmark/benchmark_model"
(string-append #$output "/bin"))))
+ (add-after 'install-extra 'install-python
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (with-directory-excursion
+ "../lite/tools/pip_package/gen/tflite_pip/python3"
+ ((assoc-ref py:%standard-phases 'install)
+ #:inputs inputs
+ #:outputs `(("out" . ,#$output:python))))))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
- (invoke "ctest" "-L" "plain")))))))
+ (invoke "ctest" "-L" "plain"))))
+ (add-after 'install-python 'add-install-to-pythonpath
+ (lambda* (#:key inputs #:allow-other-keys)
+ ((assoc-ref py:%standard-phases 'add-install-to-pythonpath)
+ #:inputs inputs
+ #:outputs `(("out" . ,#$output:python)))))
+ (add-after 'add-install-to-pythonpath 'python-sanity-check
+ (lambda* (#:key tests? inputs #:allow-other-keys)
+ ((assoc-ref py:%standard-phases 'sanity-check)
+ #:inputs `(("sanity-check.py" . ,#$(default-sanity-check.py))
+ ,@inputs)
+ #:outputs `(("out" . ,#$output:python))))))))
(inputs
(list abseil-cpp
cpuinfo
@@ 3353,15 3386,21 @@ find_library(ML_DTYPES_LIBRARIES
opencl-headers
opencl-icd-loader
pthreadpool
- python
+ python-wrapper
python-ml-dtypes
ruy
re2
xnnpack
- vulkan-headers))
+ vulkan-headers
+ zlib))
+ (propagated-inputs
+ (list python-numpy))
(native-inputs
`(("pkg-config" ,pkg-config)
("googletest" ,googletest)
+ ("pybind11" ,pybind11)
+ ("python-wheel" ,python-wheel)
+ ("swig" ,swig)
("farmhash-src"
,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
(origin