From 030f46a9db08864d27fb3edeb85a2d4a6bd600d2 Mon Sep 17 00:00:00 2001 From: Grigory Shepelev Date: Wed, 22 Apr 2026 11:02:48 +0300 Subject: [PATCH] gnu: spdk: Fix build. * gnu/packages/storage.scm (spdk)[arguments]<#:phases> {skip-python-make-subdir, install-python-package}: New phases to fix building the Python part. {wrap-python-scripts}: Adapt script names {patchelf}: Add ncurses to RUNPATH so that spdk_top can find libpanelw.so.6 and libmenuw.so.6 at runtime. [native-inputs]: Add python-installer. [inputs]: Drop python-pip, python-setuptools and python-wheel. Add python-hatchling. [description]: Add a note on missing inputs that result in commands not working as expected. Fixes: guix/guix#7916 Change-Id: Ic05547829d3f8ac018417bc3743adcb6b377a41b Signed-off-by: Andreas Enge --- gnu/packages/storage.scm | 45 ++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/gnu/packages/storage.scm b/gnu/packages/storage.scm index 38175ff118f..092f8af6c7b 100644 --- a/gnu/packages/storage.scm +++ b/gnu/packages/storage.scm @@ -404,6 +404,14 @@ clients. The key features are: (lambda _ (rmdir "isa-l") (symlink #$(package-source (this-package-input "isa-l")) "isa-l"))) + (add-after 'substitute-git-submodules 'skip-python-make-subdir + ;; SPDK's Makefile calls 'pip install' for the python subdir, but + ;; pip 25+ crashes in the sandbox (SSL cert path not found at + ;; import time). Remove python from DIRS-y and install the package + ;; ourselves in install-python-package below. + (lambda _ + (substitute* "Makefile" + (("DIRS-y \\+= python") "")))) (replace 'configure (lambda* (#:key configure-flags #:allow-other-keys) (substitute* "configure" @@ -443,7 +451,8 @@ clients. The key features are: (string-append #$(this-package-input "dpdk") "/lib") (string-append #$(this-package-input "fuse") "/lib") (string-append #$(this-package-input "gcc") "/lib") - (string-append #$(this-package-input "glibc") "/lib"))) + (string-append #$(this-package-input "glibc") "/lib") + (string-append #$(this-package-input "ncurses") "/lib"))) (rpath* (apply string-append (map (lambda (l) (string-append l ":")) libs)))) (for-each (lambda (b) @@ -459,9 +468,30 @@ clients. The key features are: binaries)))) (add-after 'patchelf 'python:wrap (assoc-ref py:%standard-phases 'wrap)) + (add-before 'python:wrap 'install-python-package + ;; Install the SPDK Python package using hatchling + installer, + ;; bypassing pip (which crashes in the sandbox due to SSL). + ;; spdk/version.py is normally generated by python/Makefile, so + ;; we recreate it here from the top-level VERSION file. + (lambda* (#:key outputs #:allow-other-keys) + (invoke "python" "-c" + (string-append + "v=open('VERSION').read().strip();" + "p=v.split('.');" + "ver=p[0]+'.'+p[1]+(('.'+p[2]) if len(p)>2 and p[2]!='0' else '');" + "open('python/spdk/version.py','w')" + ".write(\"__version__ = '\"+ver+\"'\\n\")")) + ;; ZIP format requires timestamps >= 1980; Guix normalizes + ;; source timestamps to epoch 0, so clamp SOURCE_DATE_EPOCH. + (setenv "SOURCE_DATE_EPOCH" "315532800") + (with-directory-excursion "python" + (invoke "python" "-m" "hatchling" "build" "-t" "wheel") + (let ((wheel (car (find-files "dist" "\\.whl$")))) + (invoke "python" "-m" "installer" + "--prefix" #$output wheel))))) (add-after 'python:wrap 'wrap-python-scripts (lambda* (#:key inputs #:allow-other-keys) - (let* ((scripts '("bin/spdk_cli" "bin/spdk_rpc" )) + (let* ((scripts '("bin/spdk-cli" "bin/spdk-rpc")) (dependencies (map (lambda (input) (assoc-ref inputs input)) '("python-configshell-fb"))) @@ -479,6 +509,7 @@ clients. The key features are: automake patchelf pkg-config + python-installer python-wrapper)) (inputs (list cunit @@ -499,9 +530,7 @@ clients. The key features are: openlibm openssl python-configshell-fb - python-pip ; XXX: expected by install, check why - python-setuptools ; - python-wheel ; + python-hatchling ;build backend for python/pyproject.toml (list util-linux "lib") ;; zlib zstd)) @@ -510,7 +539,11 @@ clients. The key features are: (description "@acronym{Storage Performance Development Kit, SPDK} provides a set of tools and libraries for writing high performance,scalable, user-mode storage -applications.") +applications. + +Note: the @command{spdk-mcp} binary requires the optional @code{mcp[cli]} +Python dependency, and @command{spdk-sma} requires @code{grpcio} and +@code{protobuf}. These are not currently packaged in Guix.") (license license:bsd-3))) (define-public swapspace