[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
06/07: gnu: python-pyusb: Add libusb-compat backend.
From: |
guix-commits |
Subject: |
06/07: gnu: python-pyusb: Add libusb-compat backend. |
Date: |
Wed, 27 Sep 2023 18:07:22 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 18bf6c69be5d8eceaa30a089c61272a403ec8492
Author: Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com>
AuthorDate: Wed Sep 20 12:05:27 2023 +0200
gnu: python-pyusb: Add libusb-compat backend.
* gnu/packages/libusb.scm (python-pyusb) <arguments>: Do not hard-code
libusb1 library for all back-ends, and allow to use libusb0 as a
back-end. Also enabled tests as the package does have a test suite.
* gnu/packages/libusb.scm (python-pyusb) <inputs>: Add libusb-compat.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
gnu/packages/libusb.scm | 52 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 12 deletions(-)
diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index 469882e871..d15e561668 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -288,28 +288,56 @@ wrapper for accessing libusb-1.0.")
"1fg7knfzybzija2b01pzrzhzsj989scl12sb2ra4f503l8279k54"))))
(build-system python-build-system)
(arguments
- (list #:tests? #f ; no tests
- #:modules '((srfi srfi-1)
+ (list #:modules '((srfi srfi-1)
(srfi srfi-26)
(guix build utils)
(guix build python-build-system))
#:phases
#~(modify-phases %standard-phases
+ ;; Repurpose the candidates parameter to be the path to the
+ ;; library, then on each backend we substitute the candidates
+ ;; with the full path to the .so library or with None if not
+ ;; supported.
+ ;;
+ ;; While most applications could use a single back-end this
+ ;; library allows to manually select the back-end so it is
+ ;; appropriate to provide as much back-ends as possible.
(add-after 'unpack 'fix-libusb-reference
(lambda* (#:key inputs #:allow-other-keys)
- (substitute* "usb/libloader.py"
- (("lib = locate_library\\(candidates, find_library\\)")
- (string-append
- "lib = \""
- (find (negate symbolic-link?)
- (find-files (assoc-ref inputs "libusb")
- "^libusb-.*\\.so\\..*"))
- "\""))))))))
-
+ (let ((libusb0 (find
+ (negate symbolic-link?)
+ (find-files (assoc-ref inputs
"libusb-compat")
+ "^libusb-.*\\.so\\..*")))
+ (libusb1 (find
+ (negate symbolic-link?)
+ (find-files (assoc-ref inputs "libusb")
+ "^libusb-.*\\.so\\..*"))))
+ (substitute* "usb/libloader.py"
+ (("lib = locate_library\\(candidates, find_library\\)")
+ "lib = candidates"))
+ (substitute* "usb/backend/libusb0.py"
+ (("\\('usb-0\\.1', 'usb', 'libusb0'\\)")
+ (format #f "~s" libusb0)))
+ (substitute* "usb/backend/libusb1.py"
+ (("\\('usb-1\\.0', 'libusb-1\\.0', 'usb'\\)")
+ (format #f "~s" libusb1)))
+ ;; FIXME: OpenUSB is not packaged for GNU Guix.
+ (substitute* "usb/backend/openusb.py"
+ (("\\('openusb',\\)") "None")))))
+ ;; Note: tests seems to succeed with libusb-compat as libusb
+ ;; fails because it doesn't have a usbfs present in the build
+ ;; environment.
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (when tests?
+ (with-directory-excursion "tests"
+ (setenv "PYUSB_DEBUG" "debug")
+ (setenv "LIBUSB_DEBUG" "4")
+ (invoke "python" "testall.py"))))))))
(native-inputs
(list python-setuptools-scm))
(inputs
- (list libusb))
+ (list libusb libusb-compat))
(home-page "https://pyusb.github.io/pyusb/")
(synopsis "Python bindings to the libusb library")
(description
- branch master updated (bab1d1704d -> d0438fcf65), guix-commits, 2023/09/27
- 02/07: gnu: Add blinkenlights., guix-commits, 2023/09/27
- 05/07: gnu: python-pyusb: Use G-Expressions., guix-commits, 2023/09/27
- 01/07: tests: ‘rewrite-url’ test no longer depends on network access., guix-commits, 2023/09/27
- 03/07: gnu: Add qdl., guix-commits, 2023/09/27
- 06/07: gnu: python-pyusb: Add libusb-compat backend.,
guix-commits <=
- 07/07: gnu: Add liquidctl., guix-commits, 2023/09/27
- 04/07: gnu: Add python-smbus., guix-commits, 2023/09/27