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