Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / libusb.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
3 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
5 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Theodoros Foradis <theodoros@foradis.org>
8 ;;; Copyright © 2017 Jonathan Brielmaier <jonathan.brielmaier@web.de>
9 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
11 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
12 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages libusb)
29 #:use-module (gnu packages)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix build-system ant)
36 #:use-module (guix build-system cmake)
37 #:use-module (guix build-system gnu)
38 #:use-module (guix build-system glib-or-gtk)
39 #:use-module (guix build-system python)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages gnupg)
42 #:use-module (gnu packages gtk)
43 #:use-module (gnu packages java)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages mp3)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages xiph))
51
52 (define-public libusb
53 (package
54 (name "libusb")
55 (version "1.0.23")
56 (source
57 (origin
58 (method url-fetch)
59 (uri (string-append "https://github.com/libusb/libusb/"
60 "releases/download/v" version
61 "/libusb-" version ".tar.bz2"))
62 (sha256
63 (base32 "13dd2a9x290d1q8nb1lqiaf36grcvns5ripk5k2xm0lajmpc04fv"))))
64 (build-system gnu-build-system)
65
66 ;; XXX: Enabling udev is now recommended, but eudev indirectly depends on
67 ;; libusb.
68 (arguments `(#:configure-flags '("--disable-udev")))
69 ;; (inputs `(("eudev" ,eudev)))
70
71 (home-page "https://libusb.info")
72 (synopsis "User-space USB library")
73 (description
74 "Libusb is a library that gives applications easy access to USB
75 devices on various operating systems.")
76 (license license:lgpl2.1+)))
77
78 (define-public libusb-compat
79 (package
80 (name "libusb-compat")
81 (version "0.1.5")
82 (source
83 (origin
84 (method url-fetch)
85 (uri (string-append "mirror://sourceforge/libusb/"
86 "libusb-compat-" (version-major+minor version) "/"
87 "libusb-compat-" version "/"
88 "libusb-compat-" version ".tar.bz2"))
89 (sha256
90 (base32
91 "0nn5icrfm9lkhzw1xjvaks9bq3w6mjg86ggv3fn7kgi4nfvg8kj0"))))
92 (build-system gnu-build-system)
93 (native-inputs
94 `(("pkg-config" ,pkg-config)))
95 (inputs
96 `(("libusb" ,libusb)))
97 (home-page "https://libusb.info")
98 (synopsis "Compatibility shim for libusb")
99 (description
100 "Libusb-compat provides a shim allowing applications based on older
101 version of libusb to run with newer libusb.")
102 (license license:lgpl2.1+)))
103
104 ;; required by 0xffff, which compiles with libusb-compat, but executes only
105 ;; with libusb-0.1
106 (define-public libusb-0.1
107 (package (inherit libusb)
108 (version "0.1.12")
109 (source
110 (origin
111 (method url-fetch)
112 (uri (string-append "mirror://sourceforge/libusb/libusb-0.1 (LEGACY)/"
113 version "/libusb-" version ".tar.gz"))
114 (sha256
115 (base32
116 "0i4bacxkyr7xyqxbmb00ypkrv4swkgm0mghbzjsnw6blvvczgxip"))
117 (patches (search-patches "libusb-0.1-disable-tests.patch"))))))
118
119 (define-public libusb4java
120 ;; There is no public release so we take the latest version from git.
121 (let ((commit "396d642a57678a0d9663b062c980fe100cc0ea1e")
122 (revision "1"))
123 (package
124 (name "libusb4java")
125 (version (string-append "0-" revision "." (string-take commit 9)))
126 (source (origin
127 (method git-fetch)
128 (uri (git-reference
129 (url "https://github.com/usb4java/libusb4java.git")
130 (commit commit)))
131 (file-name (git-file-name name version))
132 (sha256
133 (base32
134 "0wqgapalhfh9v38ycbl6i2f5lh1wpr6fzwn5dwd0rdacypkd1gml"))))
135 (build-system cmake-build-system)
136 (arguments
137 `(#:tests? #f ; there are no tests
138 #:phases
139 (modify-phases %standard-phases
140 ;; FIXME: libusb 1.0.22 deprecated libusb_set_debug, so the build
141 ;; fails because libusb4java uses a deprecated procedure.
142 (add-after 'unpack 'disable-Werror
143 (lambda _
144 (substitute* "CMakeLists.txt"
145 (("-Werror") ""))
146 #t))
147 (add-before 'configure 'set-JAVA_HOME
148 (lambda* (#:key inputs #:allow-other-keys)
149 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
150 #t)))))
151 (inputs
152 `(("libusb" ,libusb)))
153 (native-inputs
154 `(("jdk" ,icedtea "jdk")))
155 (home-page "https://github.com/usb4java/libusb4java/")
156 (synopsis "JNI bindings to libusb")
157 (description
158 "This package provides Java JNI bindings to the libusb library for use
159 with usb4java.")
160 (license license:expat))))
161
162 (define-public java-usb4java
163 (package
164 (name "java-usb4java")
165 (version "1.2.0")
166 (source (origin
167 (method url-fetch)
168 (uri (string-append "https://github.com/usb4java/usb4java/"
169 "archive/usb4java-" version ".tar.gz"))
170 (sha256
171 (base32
172 "0gzpsnzwgsdyra3smq288yvxnwrgvdwxr6g8jbknnsk56kv6wc34"))))
173 (build-system ant-build-system)
174 (arguments
175 `(#:jar-name "usb4java.jar"
176 #:phases
177 (modify-phases %standard-phases
178 ;; Usually, native libusb4java libraries for all supported systems
179 ;; would be included in the jar and extracted at runtime. Since we
180 ;; build everything from source we cannot just bundle pre-built
181 ;; binaries for other systems. Instead, we patch the loader to
182 ;; directly return the appropriate library for this system. The
183 ;; downside is that the jar will only work on the same architecture
184 ;; that it was built on.
185 (add-after 'unpack 'copy-libusb4java
186 (lambda* (#:key inputs #:allow-other-keys)
187 (substitute* "src/main/java/org/usb4java/Loader.java"
188 (("private static String extractLibrary" line)
189 (string-append
190 line "(final String a, final String b) {"
191 "return \""
192 (assoc-ref inputs "libusb4java") "/lib/libusb4java.so"
193 "\"; }\n"
194 "private static String _extractLibrary")))
195 #t))
196 (add-after 'unpack 'disable-broken-tests
197 (lambda _
198 (with-directory-excursion "src/test/java/org/usb4java"
199 ;; These tests should only be run when USB devices are present.
200 (substitute* '("LibUsbGlobalTest.java"
201 "TransferTest.java")
202 (("this.context = new Context\\(\\);")
203 "this.context = null;")
204 (("LibUsb.init") "//"))
205 (substitute* "DeviceListIteratorTest.java"
206 (("this.iterator.remove" line)
207 (string-append "assumeUsbTestsEnabled();" line))))
208 #t)))))
209 (inputs
210 `(("libusb4java" ,libusb4java)
211 ("java-commons-lang3" ,java-commons-lang3)
212 ("java-junit" ,java-junit)
213 ("java-hamcrest-core" ,java-hamcrest-core)))
214 (home-page "http://usb4java.org/")
215 (synopsis "USB library for Java")
216 (description
217 "This package provides a USB library for Java based on libusb and
218 implementing @code{javax.usb} (JSR-80).")
219 (license license:expat)))
220
221 (define-public python-libusb1
222 (package
223 (name "python-libusb1")
224 (version "1.6.4")
225 (source
226 (origin
227 (method url-fetch)
228 (uri (pypi-uri "libusb1" version))
229 (sha256
230 (base32
231 "03b7xrz8vqg8w0za5r503jhcmbd1ls5610jcja1rqz833nf0v4wc"))))
232 (build-system python-build-system)
233 (arguments
234 `(#:modules ((srfi srfi-1)
235 (guix build utils)
236 (guix build python-build-system))
237 #:phases
238 (modify-phases %standard-phases
239 (add-before 'install-license-files 'remove-incorrect-license
240 (lambda* (#:key out #:allow-other-keys)
241 ;; Was relicensed to LGPL 2.1+, but old COPYING file still left
242 ;; in source. Remove it so it does not get installed.
243 (delete-file "COPYING")
244 #t))
245 (add-after 'unpack 'fix-libusb-reference
246 (lambda* (#:key inputs #:allow-other-keys)
247 (substitute* "usb1/libusb1.py"
248 (("libusb_path = ctypes.util.find_library\\(base_name\\)")
249 (string-append
250 "libusb_path = \""
251 (find (negate symbolic-link?)
252 (find-files (assoc-ref inputs "libusb")
253 "^libusb.*\\.so\\..*"))
254 "\"")))
255 #t)))))
256 (inputs `(("libusb" ,libusb)))
257 (home-page "https://github.com/vpelletier/python-libusb1")
258 (synopsis "Pure-python wrapper for libusb-1.0")
259 (description "Libusb is a library that gives applications easy access to
260 USB devices on various operating systems. This package provides a Python
261 wrapper for accessing libusb-1.0.")
262 (license license:lgpl2.1+)))
263
264 (define-public python-pyusb
265 (package
266 (name "python-pyusb")
267 (version "1.0.2")
268 (source
269 (origin
270 (method url-fetch)
271 (uri (pypi-uri "pyusb" version))
272 (sha256
273 (base32
274 "0qkk2jn270jwwl1x26hmdhb14m9kkbrzzwzizdjcl1a29b6756sf"))))
275 (build-system python-build-system)
276 (arguments
277 `(#:tests? #f ; no tests
278 #:modules ((srfi srfi-1)
279 (srfi srfi-26)
280 (guix build utils)
281 (guix build python-build-system))
282 #:phases
283 (modify-phases %standard-phases
284 (add-after 'unpack 'fix-libusb-reference
285 (lambda* (#:key inputs #:allow-other-keys)
286 (substitute* "usb/libloader.py"
287 (("lib = locate_library\\(candidates, find_library\\)")
288 (string-append
289 "lib = \""
290 (find (negate symbolic-link?)
291 (find-files (assoc-ref inputs "libusb")
292 "^libusb-.*\\.so\\..*"))
293 "\"")))
294 #t)))))
295 (inputs
296 `(("libusb" ,libusb)))
297 (home-page "https://pyusb.github.io/pyusb/")
298 (synopsis "Python bindings to the libusb library")
299 (description
300 "PyUSB aims to be an easy to use Python module to access USB devices.")
301 (license license:bsd-3)))
302
303 (define-public python2-pyusb
304 (package-with-python2 python-pyusb))
305
306 (define-public python-capablerobot-usbhub
307 (package
308 (name "python-capablerobot-usbhub")
309 (version "0.2.7")
310 (source
311 (origin
312 (method url-fetch)
313 (uri (pypi-uri "capablerobot_usbhub" version))
314 (sha256
315 (base32
316 "1priic4iq2vn1rc711kzxwhxrwa508rkxrr193qdz2lw26kdhvix"))))
317 (build-system python-build-system)
318 (arguments
319 `(#:phases
320 (modify-phases %standard-phases
321 (add-after 'install 'install-udev-rules
322 (lambda* (#:key outputs #:allow-other-keys)
323 (let ((out (assoc-ref outputs "out")))
324 (mkdir-p (string-append out "/lib/udev/rules.d"))
325 (copy-file "50-capablerobot-usbhub.rules"
326 (string-append out
327 "/lib/udev/rules.d/"
328 "50-capablerobot-usbhub.rules"))
329 #t))))))
330 (propagated-inputs
331 `(("python-click" ,python-click)
332 ("python-construct" ,python-construct)
333 ("python-pyusb" ,python-pyusb)
334 ("python-pyyaml" ,python-pyyaml)))
335 (home-page
336 "https://github.com/CapableRobot/CapableRobot_USBHub_Driver")
337 (synopsis
338 "Host side driver for the Capable Robot Programmable USB Hub")
339 (description
340 "This package provides access to the internal state of the Capable Robot
341 USB Hub, allowing you to monitor and control the Hub from an upstream
342 computer. It also creates a transparent CircuitPython Bridge, allowing
343 unmodified CircuitPython code to run on the host computer and interact with
344 I2C and SPI devices attached to the USB Hub.")
345 (license license:expat)))
346
347 (define-public libplist
348 (package
349 (name "libplist")
350 (version "2.1.0")
351 (source
352 (origin
353 (method git-fetch)
354 (uri (git-reference
355 (url "https://github.com/libimobiledevice/libplist.git")
356 (commit version)))
357 (file-name (git-file-name name version))
358 (sha256
359 (base32 "02vraf4j46bp746s0gz7vga2gv2dy3zd1v1bsy9x8algg9fpcb7n"))))
360 (build-system gnu-build-system)
361 (arguments
362 `(;; Tests fail randomly when run in parallel because several of them write
363 ;; and read to/from the same file--e.g., "4.plist" is accessed by
364 ;; 'large.test' and 'largecmp.test'.
365 #:parallel-tests? #f))
366 (inputs
367 `(("python" ,python)))
368 (native-inputs
369 `(("autoconf" ,autoconf)
370 ("automake" ,automake)
371 ("libtool" ,libtool)
372 ("pkg-config" ,pkg-config)
373 ("python-cython" ,python-cython))) ; to build Python bindings
374 (home-page "https://www.libimobiledevice.org/")
375 (synopsis "C library to handle Apple Property List files")
376 (description "This package provides a small portable C library to handle
377 Apple Property List files in binary or XML.")
378 (license license:lgpl2.1+)))
379
380 (define-public libusbmuxd
381 (package
382 (name "libusbmuxd")
383 (version "1.0.10")
384 (source (origin
385 (method url-fetch)
386 (uri (string-append "https://www.libimobiledevice.org/downloads/"
387 "libusbmuxd-" version ".tar.bz2"))
388 (sha256
389 (base32
390 "1wn9zq2224786mdr12c5hxad643d29wg4z6b7jn888jx4s8i78hs"))))
391 (build-system gnu-build-system)
392 (native-inputs
393 `(("pkg-config" ,pkg-config)
394 ("libplist" ,libplist)))
395 (home-page "https://www.libimobiledevice.org/")
396 (synopsis "Library to multiplex connections from and to iOS devices")
397 (description "This package provides a client library to multiplex
398 connections from and to iOS devices by connecting to a socket provided by a
399 @code{usbmuxd} daemon.")
400 (license license:lgpl2.1+)))
401
402 ;; These patches are needed to build with Python 3.8.
403 (define %libimobiledevice-patches
404 (list (origin
405 (method url-fetch)
406 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
407 "/commit/1ff3448d2e27f1bac8d2f0af8b8e952854860278.patch"))
408 (file-name "libimobiledevice-python-config.patch")
409 (sha256
410 (base32
411 "1mkwhp8vvhajij29jk3w4rkgcfh8d8waf908drh3076k70hb6i8y")))
412 (origin
413 (method url-fetch)
414 (uri (string-append "https://github.com/libimobiledevice/libimobiledevice"
415 "/commit/eea4f1be9107c8ab621fd71460e47d0d38e55d71.patch"))
416 (file-name "libimobiledevice-python-3.8-compat.patch")
417 (sha256
418 (base32
419 "1zz8v7kgwyq5ck1qp03l29pcmljygnjwls9d6q28nv5pkwa6848w")))))
420
421 (define-public libimobiledevice
422 (package
423 (name "libimobiledevice")
424 (version "1.2.0")
425 (source (origin
426 (method url-fetch)
427 (uri (string-append "https://www.libimobiledevice.org/downloads/"
428 "libimobiledevice-" version ".tar.bz2"))
429 ;; Note: Remove the 'force-bootstrap' phase and the autoconf
430 ;; inputs below when removing these patches.
431 (patches %libimobiledevice-patches)
432 (sha256
433 (base32
434 "0dqhy4qwj30mw8pwckvjmgnj1qqrh6p8c6jknmhvylshhzh0ssvq"))))
435 (build-system gnu-build-system)
436 (arguments
437 `(#:phases (modify-phases %standard-phases
438 (add-before 'bootstrap 'force-bootstrap
439 (lambda _
440 (delete-file "configure")
441 #t)))))
442 (propagated-inputs
443 `(("openssl" ,openssl-1.0)
444 ("libplist" ,libplist)
445 ("libusbmuxd" ,libusbmuxd)))
446 (inputs
447 `(("python" ,python)))
448 (native-inputs
449 `(("pkg-config" ,pkg-config)
450 ("python-cython" ,python-cython)
451
452 ;; These are required because we patch and bootstrap the build system.
453 ("autoconf" ,autoconf)
454 ("automake" ,automake)
455 ("libtool" ,libtool)))
456 (home-page "https://www.libimobiledevice.org/")
457 (synopsis "Protocol library and tools to communicate with Apple devices")
458 (description "libimobiledevice is a software library that talks the
459 protocols to support Apple devices. It allows other software to easily access
460 the device's file system, retrieve information about the device and its
461 internals, backup/restore the device, manage installed applications, retrieve
462 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
463 music and video to the device.")
464 (license license:lgpl2.1+)))
465
466 (define-public ifuse
467 (package
468 (name "ifuse")
469 (version "1.1.3")
470 (source (origin
471 (method url-fetch)
472 (uri (string-append "https://www.libimobiledevice.org/downloads/"
473 "ifuse-" version ".tar.bz2"))
474 (sha256
475 (base32
476 "1p9a4n36jb194cnp6v57cz2bggwbywaz8pbpb95ch83pzdkdx257"))))
477 (inputs
478 `(("fuse" ,fuse)
479 ("libimobiledevice" ,libimobiledevice)))
480 (native-inputs
481 `(("pkg-config" ,pkg-config)))
482 (build-system gnu-build-system)
483 (home-page "https://www.libimobiledevice.org/")
484 (synopsis "Mount iOS devices")
485 (description "This package provides @command{ifuse}, a command to mount
486 iOS devices and access their contents.")
487 (license license:lgpl2.1+)))
488
489 (define-public usbmuxd
490 (package
491 (name "usbmuxd")
492 (version "1.1.0")
493 (source (origin
494 (method url-fetch)
495 (uri (string-append "https://www.libimobiledevice.org/downloads/"
496 "usbmuxd-" version ".tar.bz2"))
497 (sha256
498 (base32
499 "0bdlc7a8plvglqqx39qqampqm6y0hcdws76l9dffwl22zss4i29y"))))
500 (inputs
501 `(("libplist" ,libplist)
502 ("libusb" ,libusb)
503 ("libimobiledevice" ,libimobiledevice)))
504 (native-inputs
505 `(("pkg-config" ,pkg-config)))
506 (build-system gnu-build-system)
507 (home-page "https://www.libimobiledevice.org/")
508 (synopsis "Multiplex connections over USB to an iOS device")
509 (description "This package provides the @code{usbmuxd} daemon
510 which multiplexes connections over USB to an iOS device. To
511 users, it means you can sync your music, contacts, photos, etc.
512 over USB.")
513 (license license:gpl2+)))
514
515 (define-public libmtp
516 (package
517 (name "libmtp")
518 (version "1.1.17")
519 (source (origin
520 (method url-fetch)
521 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
522 "/libmtp-" version ".tar.gz"))
523 (sha256
524 (base32
525 "1p3r38nvdip40ab1h4scj3mzfjkx6kd14szjqyw9r6wz5pslr8zq"))))
526 (build-system gnu-build-system)
527 (native-inputs
528 `(("pkg-config" ,pkg-config)))
529 (inputs
530 `(("libgcrypt" ,libgcrypt)))
531 (propagated-inputs
532 ;; libmtp.pc refers to all these.
533 `(("libusb" ,libusb)))
534 (arguments
535 `(#:configure-flags
536 (list "--disable-static"
537 (string-append "--with-udev="
538 (assoc-ref %outputs "out")
539 "/lib/udev"))))
540 (home-page "http://libmtp.sourceforge.net/")
541 (synopsis "Library implementing the Media Transfer Protocol")
542 (description "Libmtp implements an MTP (Media Transfer Protocol)
543 initiator, which means that it initiates MTP sessions with devices. The
544 devices responding are known as MTP responders. Libmtp runs on devices
545 with a USB host controller interface. It implements MTP Basic, which was
546 proposed for standardization.")
547 ;; COPYING contains lgpl2.1, while files headers give
548 ;; "GNU Lesser General Public License as published by the Free Software
549 ;; Foundation; either version 2 of the License, or (at your option) any
550 ;; later version."
551 (license license:lgpl2.1+)))
552
553 (define-public gmtp
554 (package
555 (name "gmtp")
556 (version "1.3.11")
557 (source (origin
558 (method url-fetch)
559 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
560 "/gmtp-" version ".tar.gz"))
561 (sha256
562 (base32
563 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
564 (build-system glib-or-gtk-build-system)
565 (arguments
566 '(#:configure-flags
567 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
568 (list
569 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
570 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
571 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
572 (inputs
573 `(("gtk+" ,gtk+)
574 ("flac" ,flac)
575 ("libvorbis" ,libvorbis)
576 ("libid3tag" ,libid3tag)
577 ("libmtp" ,libmtp)))
578 (native-inputs
579 `(("pkg-config" ,pkg-config)))
580 (home-page "http://gmtp.sourceforge.net/")
581 (synopsis "Simple graphical MTP client")
582 (description "gMTP is a simple graphical client for the Media Transfer Protocol
583 (MTP), which allows media files to be transferred to and from many portable
584 devices.")
585 (license license:bsd-3)))
586
587 (define-public hidapi
588 (package
589 (name "hidapi")
590 (version "0.9.0")
591 (source
592 (origin
593 (method git-fetch)
594 (uri (git-reference
595 (url "https://github.com/libusb/hidapi.git")
596 (commit (string-append "hidapi-" version))))
597 (file-name (git-file-name name version))
598 (sha256
599 (base32 "1p4g8lgwj4rki6lbn5l6rvwj0xlbn1xfh4d255bg5pvgczmwmc4i"))))
600 (build-system gnu-build-system)
601 (inputs
602 `(("libusb" ,libusb)
603 ("udev" ,eudev)))
604 (native-inputs
605 `(("autoconf" ,autoconf)
606 ("automake" ,automake)
607 ("libtool" ,libtool)
608 ("pkg-config" ,pkg-config)))
609 (home-page "https://github.com/libusb/hidapi")
610 (synopsis "HID API library")
611 (description
612 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
613 HID-Class devices.")
614 ;; HIDAPI can be used under one of three licenses.
615 (license (list license:gpl3
616 license:bsd-3
617 (license:non-copyleft "file://LICENSE-orig.txt")))))
618
619 (define-public python-hidapi
620 (package
621 (name "python-hidapi")
622 (version "0.7.99.post21")
623 (source
624 (origin
625 (method url-fetch)
626 (uri (pypi-uri "hidapi" version))
627 (sha256
628 (base32
629 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
630 (modules '((guix build utils)))
631 (snippet
632 ;; Remove bundled libraries.
633 '(begin
634 (delete-file-recursively "hidapi")
635 #t))))
636 (build-system python-build-system)
637 (arguments
638 `(#:phases
639 (modify-phases %standard-phases
640 (add-after 'unpack 'patch-configuration
641 (lambda* (#:key inputs #:allow-other-keys)
642 (substitute* "setup.py"
643 (("'/usr/include/libusb-1.0'")
644 (string-append "'" (assoc-ref inputs "libusb")
645 "/include/libusb-1.0'"))
646 (("'/usr/include/hidapi'")
647 (string-append "'" (assoc-ref inputs "hidapi")
648 "/include/hidapi'")))
649 #t))
650 ;; XXX Necessary because python-build-system drops the arguments.
651 (replace 'build
652 (lambda _
653 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
654 (replace 'check
655 (lambda _
656 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
657 (replace 'install
658 (lambda* (#:key outputs #:allow-other-keys)
659 (invoke "python" "setup.py" "install" "--with-system-hidapi"
660 (string-append "--prefix=" (assoc-ref outputs "out"))
661 "--single-version-externally-managed" "--root=/"))))))
662 (inputs
663 `(("hidapi" ,hidapi)
664 ("libusb" ,libusb)
665 ("eudev" ,eudev)))
666 (native-inputs
667 `(("python-cython" ,python-cython)))
668 (home-page "https://github.com/trezor/cython-hidapi")
669 (synopsis "Cython interface to hidapi")
670 (description "This package provides a Cython interface to @code{hidapi}.")
671 ;; The library can be used under either of these licenses.
672 (license (list license:gpl3
673 license:bsd-3
674 (license:non-copyleft
675 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
676 "You are free to use cython-hidapi code for any purpose.")))))
677
678 (define-public python2-hidapi
679 (package-with-python2 python-hidapi))