diff mbox series

[bug#42682,v3,7/9] gnu: Add python-hid.

Message ID e713c0705f257f70165c13c544eca48b523f8104.1685316748.git.plattfot@posteo.net
State New
Headers show
Series Add qmk-cli | expand

Commit Message

Fredrik Salomonsson May 28, 2023, 11:44 p.m. UTC
* gnu/packages/libusb.scm (python-hid): New variable.
---
 gnu/packages/libusb.scm | 56 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index d0837c8a91..8e81b0c1a9 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -13,6 +13,7 @@ 
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2022 Jacob Hrbek <kreyren@rixotstudio.cz>
 ;;; Copyright © 2023 Sharlatan Hellseher <sharlatanus@gmail.com>
+;;; Copyright © 2023 Fredrik Salomonsson <plattfot@posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -44,6 +45,7 @@  (define-module (gnu packages libusb)
   #:use-module (guix build-system pyproject)
   #:use-module (guix build-system python)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages gnupg)
@@ -54,6 +56,7 @@  (define-module (gnu packages libusb)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-build)
+  #:use-module (gnu packages python-check)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages tls)
@@ -650,6 +653,59 @@  (define-public hidapi
                    license:bsd-3
                    (license:non-copyleft "file://LICENSE-orig.txt")))))
 
+(define-public python-hid
+  (package
+    (name "python-hid")
+    (version "1.0.5")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "hid" version))
+              (sha256
+               (base32
+                "1s5hvfbmnlmifswr5514f4xxn5rcd429bdcdqzgwkdxrg9zlx58y"))))
+    (build-system python-build-system)
+    (arguments
+       (list
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'patch-library-paths
+              (lambda* (#:key inputs #:allow-other-keys)
+                (substitute* '("hid/__init__.py")
+                  (("'libhidapi-hidraw.so'")
+                   (string-append
+                    "'" (search-input-file inputs "/lib/libhidapi-hidraw.so") "'"))
+                  (("'libhidapi-libusb.so'")
+                   (string-append
+                    "'" (search-input-file inputs "/lib/libhidapi-libusb.so") "'"))
+                  ;; Nuke the rest of the library_paths
+                  (("[[:blank:]]+'libhidapi-hidraw.so.0',\n")
+                   "")
+                  (("[[:blank:]]+'libhidapi-libusb.so.0',\n")
+                   "")
+                  (("[[:blank:]]+'libhidapi-iohidmanager.so',\n")
+                   "")
+                  (("[[:blank:]]+'libhidapi-iohidmanager.so.0',\n")
+                   "")
+                  (("[[:blank:]]+'libhidapi.dylib',\n")
+                   "")
+                  (("[[:blank:]]+'hidapi.dll',\n")
+                   "")
+                  (("[[:blank:]]+'hidapi-0.dll',\n")
+                   "")))))))
+    (native-inputs
+     (list
+      python-nose
+      python-tox))
+    (inputs
+     (list
+      hidapi))
+    (home-page "https://github.com/apmorton/pyhidapi")
+    (synopsis "Ctypes bindings for hidapi")
+    (description "This package provides ctypes bindings in Python for the @code{hidapi}
+package.  Note that this package conflicts with the
+@code{python-hidapi} package as they occupy the same Python namespace.")
+    (license license:expat)))
+
 (define-public python-hidapi
   (package
     (name "python-hidapi")