gnu: emacs-svg-icon: Fix grammar.
[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, 2020 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.24")
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 "0amilbi5qncdnrds3ji21vbiz1wvdm1fwp5qrxnk49xkyy2jdzby"))))
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")
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.2.0")
355 (source
356 (origin
357 (method url-fetch)
358 (uri (string-append "https://github.com/libimobiledevice"
359 "/libplist/releases/download/" version
360 "/libplist-" version ".tar.bz2"))
361 (sha256
362 (base32 "16mxdwaw01x9a3adf0yj3bqjc7afpf2vm1n5hkgj3i3y6zjifmaa"))))
363 (build-system gnu-build-system)
364 (arguments
365 `(;; Tests fail randomly when run in parallel because several of them write
366 ;; and read to/from the same file--e.g., "4.plist" is accessed by
367 ;; 'large.test' and 'largecmp.test'.
368 #:parallel-tests? #f))
369 (inputs
370 `(("python" ,python)))
371 (native-inputs
372 `(("autoconf" ,autoconf)
373 ("automake" ,automake)
374 ("libtool" ,libtool)
375 ("pkg-config" ,pkg-config)
376 ("python-cython" ,python-cython))) ; to build Python bindings
377 (home-page "https://libimobiledevice.org/")
378 (synopsis "C library to handle Apple Property List files")
379 (description "This package provides a small portable C library to handle
380 Apple Property List files in binary or XML.")
381 (license license:lgpl2.1+)))
382
383 (define-public libusbmuxd
384 (package
385 (name "libusbmuxd")
386 (version "2.0.2")
387 (source (origin
388 (method url-fetch)
389 (uri (string-append "https://github.com/libimobiledevice"
390 "/libusbmuxd/releases/download/" version
391 "/libusbmuxd-" version ".tar.bz2"))
392 (sha256
393 (base32
394 "084vg570g1qb506jd7axg6c080mfsmbf52v3lngzlknsaf2q0snc"))))
395 (build-system gnu-build-system)
396 (native-inputs
397 `(("pkg-config" ,pkg-config)
398 ("libplist" ,libplist)))
399 (home-page "https://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 (define-public libimobiledevice
407 (package
408 (name "libimobiledevice")
409 (version "1.3.0")
410 (source (origin
411 (method url-fetch)
412 (uri (string-append "https://github.com/libimobiledevice"
413 "/libimobiledevice/releases/download/"
414 version "/libimobiledevice-" version
415 ".tar.bz2"))
416 (sha256
417 (base32
418 "1xmhfnypg6j7shl73wfkrrn4mj9dh8qzaj3258q9zkb5cc669wjk"))))
419 (build-system gnu-build-system)
420 (arguments
421 '(#:configure-flags '("PYTHON_VERSION=3")))
422 (propagated-inputs
423 `(("openssl" ,openssl)
424 ("libplist" ,libplist)
425 ("libusbmuxd" ,libusbmuxd)))
426 (inputs
427 `(("python" ,python)))
428 (native-inputs
429 `(("pkg-config" ,pkg-config)
430 ("python-cython" ,python-cython)))
431 (home-page "https://libimobiledevice.org/")
432 (synopsis "Protocol library and tools to communicate with Apple devices")
433 (description "libimobiledevice is a software library that talks the
434 protocols to support Apple devices. It allows other software to easily access
435 the device's file system, retrieve information about the device and its
436 internals, backup/restore the device, manage installed applications, retrieve
437 address books, calendars, notes, and bookmarks, and (using libgpod) synchronize
438 music and video to the device.")
439 (license license:lgpl2.1+)))
440
441 (define-public ifuse
442 (package
443 (name "ifuse")
444 (version "1.1.4")
445 (source (origin
446 (method url-fetch)
447 (uri (string-append "https://github.com/libimobiledevice"
448 "/ifuse/releases/download/" version
449 "/ifuse-" version ".tar.bz2"))
450 (sha256
451 (base32
452 "11wdv44qwia77sh38n36809ysaib52rwd4fvqwb5ybsbz4p70l1m"))))
453 (inputs
454 `(("fuse" ,fuse)
455 ("libimobiledevice" ,libimobiledevice)))
456 (native-inputs
457 `(("pkg-config" ,pkg-config)))
458 (build-system gnu-build-system)
459 (home-page "https://libimobiledevice.org/")
460 (synopsis "Mount iOS devices")
461 (description "This package provides @command{ifuse}, a command to mount
462 iOS devices and access their contents.")
463 (license license:lgpl2.1+)))
464
465 (define-public usbmuxd
466 (package
467 (name "usbmuxd")
468 (version "1.1.1")
469 (source (origin
470 (method url-fetch)
471 (uri (string-append "https://github.com/libimobiledevice"
472 "/usbmuxd/releases/download/" version
473 "/usbmuxd-" version ".tar.bz2"))
474 (sha256
475 (base32
476 "17idzpxrvkbff0jpynf35df95lh7wsm8vndynp63bxib2w09gv60"))))
477 (inputs
478 `(("libplist" ,libplist)
479 ("libusb" ,libusb)
480 ("libimobiledevice" ,libimobiledevice)))
481 (native-inputs
482 `(("pkg-config" ,pkg-config)))
483 (build-system gnu-build-system)
484 (home-page "https://libimobiledevice.org/")
485 (synopsis "Multiplex connections over USB to an iOS device")
486 (description "This package provides the @code{usbmuxd} daemon
487 which multiplexes connections over USB to an iOS device. To
488 users, it means you can sync your music, contacts, photos, etc.
489 over USB.")
490 (license license:gpl2+)))
491
492 (define-public libmtp
493 (package
494 (name "libmtp")
495 (version "1.1.18")
496 (source (origin
497 (method url-fetch)
498 (uri (string-append "mirror://sourceforge/libmtp/libmtp/" version
499 "/libmtp-" version ".tar.gz"))
500 (sha256
501 (base32
502 "1w41l93yi0dmw218daiw36rylkc8rammxx37csh1ij24q18gx03j"))))
503 (build-system gnu-build-system)
504 (native-inputs
505 `(("pkg-config" ,pkg-config)))
506 (inputs
507 `(("libgcrypt" ,libgcrypt)))
508 (propagated-inputs
509 ;; libmtp.pc refers to all these.
510 `(("libusb" ,libusb)))
511 (arguments
512 `(#:configure-flags
513 (list "--disable-static"
514 (string-append "--with-udev="
515 (assoc-ref %outputs "out")
516 "/lib/udev"))))
517 (home-page "http://libmtp.sourceforge.net/")
518 (synopsis "Library implementing the Media Transfer Protocol")
519 (description "Libmtp implements an MTP (Media Transfer Protocol)
520 initiator, which means that it initiates MTP sessions with devices. The
521 devices responding are known as MTP responders. Libmtp runs on devices
522 with a USB host controller interface. It implements MTP Basic, which was
523 proposed for standardization.")
524 ;; COPYING contains lgpl2.1, while files headers give
525 ;; "GNU Lesser General Public License as published by the Free Software
526 ;; Foundation; either version 2 of the License, or (at your option) any
527 ;; later version."
528 (license license:lgpl2.1+)))
529
530 (define-public gmtp
531 (package
532 (name "gmtp")
533 (version "1.3.11")
534 (source (origin
535 (method url-fetch)
536 (uri (string-append "mirror://sourceforge/gmtp/gMTP-" version
537 "/gmtp-" version ".tar.gz"))
538 (sha256
539 (base32
540 "04q6byyq002fhzkc2rkkahwh5b6272xakaj4m3vwm8la8jf0r0ss"))))
541 (build-system glib-or-gtk-build-system)
542 (arguments
543 '(#:configure-flags
544 (let ((libid3tag (assoc-ref %build-inputs "libid3tag")))
545 (list
546 ;; libid3tag provides no .pc file, so pkg-config fails to find them.
547 (string-append "ID3TAG_CFLAGS=-I" libid3tag "/include")
548 (string-append "ID3TAG_LIBS=-L" libid3tag "/lib -lid3tag -lz")))))
549 (inputs
550 `(("gtk+" ,gtk+)
551 ("flac" ,flac)
552 ("libvorbis" ,libvorbis)
553 ("libid3tag" ,libid3tag)
554 ("libmtp" ,libmtp)))
555 (native-inputs
556 `(("pkg-config" ,pkg-config)))
557 (home-page "http://gmtp.sourceforge.net/")
558 (synopsis "Simple graphical MTP client")
559 (description "gMTP is a simple graphical client for the Media Transfer Protocol
560 (MTP), which allows media files to be transferred to and from many portable
561 devices.")
562 (license license:bsd-3)))
563
564 (define-public hidapi
565 (package
566 (name "hidapi")
567 (version "0.10.1")
568 (source
569 (origin
570 (method git-fetch)
571 (uri (git-reference
572 (url "https://github.com/libusb/hidapi")
573 (commit (string-append "hidapi-" version))))
574 (file-name (git-file-name name version))
575 (sha256
576 (base32 "1nr4z4b10vpbh3ss525r7spz4i43zim2ba5qzfl15dgdxshxxivb"))))
577 (build-system gnu-build-system)
578 (inputs
579 `(("libusb" ,libusb)
580 ("udev" ,eudev)))
581 (native-inputs
582 `(("autoconf" ,autoconf)
583 ("automake" ,automake)
584 ("libtool" ,libtool)
585 ("pkg-config" ,pkg-config)))
586 (home-page "https://github.com/libusb/hidapi")
587 (synopsis "HID API library")
588 (description
589 "HIDAPI is a library which allows an application to interface with USB and Bluetooth
590 HID-Class devices.")
591 ;; HIDAPI can be used under one of three licenses.
592 (license (list license:gpl3
593 license:bsd-3
594 (license:non-copyleft "file://LICENSE-orig.txt")))))
595
596 (define-public python-hidapi
597 (package
598 (name "python-hidapi")
599 (version "0.7.99.post21")
600 (source
601 (origin
602 (method url-fetch)
603 (uri (pypi-uri "hidapi" version))
604 (sha256
605 (base32
606 "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
607 (modules '((guix build utils)))
608 (snippet
609 ;; Remove bundled libraries.
610 '(begin
611 (delete-file-recursively "hidapi")
612 #t))))
613 (build-system python-build-system)
614 (arguments
615 `(#:phases
616 (modify-phases %standard-phases
617 (add-after 'unpack 'patch-configuration
618 (lambda* (#:key inputs #:allow-other-keys)
619 (substitute* "setup.py"
620 (("'/usr/include/libusb-1.0'")
621 (string-append "'" (assoc-ref inputs "libusb")
622 "/include/libusb-1.0'"))
623 (("'/usr/include/hidapi'")
624 (string-append "'" (assoc-ref inputs "hidapi")
625 "/include/hidapi'")))
626 #t))
627 ;; XXX Necessary because python-build-system drops the arguments.
628 (replace 'build
629 (lambda _
630 (invoke "python" "setup.py" "build" "--with-system-hidapi")))
631 (replace 'check
632 (lambda _
633 (invoke "python" "setup.py" "test" "--with-system-hidapi")))
634 (replace 'install
635 (lambda* (#:key outputs #:allow-other-keys)
636 (invoke "python" "setup.py" "install" "--with-system-hidapi"
637 (string-append "--prefix=" (assoc-ref outputs "out"))
638 "--single-version-externally-managed" "--root=/"))))))
639 (inputs
640 `(("hidapi" ,hidapi)
641 ("libusb" ,libusb)
642 ("eudev" ,eudev)))
643 (native-inputs
644 `(("python-cython" ,python-cython)))
645 (home-page "https://github.com/trezor/cython-hidapi")
646 (synopsis "Cython interface to hidapi")
647 (description "This package provides a Cython interface to @code{hidapi}.")
648 ;; The library can be used under either of these licenses.
649 (license (list license:gpl3
650 license:bsd-3
651 (license:non-copyleft
652 "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt"
653 "You are free to use cython-hidapi code for any purpose.")))))
654
655 (define-public python2-hidapi
656 (package-with-python2 python-hidapi))