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