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