[PATCH] gnu: Add python-hidapi.

  • Done
  • quality assurance status badge
Details
3 participants
  • Danny Milosavljevic
  • Leo Famulari
  • Marius Bakke
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 7 years ago
(address . guix-patches@gnu.org)
20171226000319.6b5c478f@scratchpost.org
* gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.
---
gnu/packages/libusb.scm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index 31c7dfa44..404ae8659 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -352,3 +352,40 @@ HID-Class devices.")
(license (list gpl3
bsd-3
(non-copyleft "file://LICENSE-orig.txt")))))
+
+(define-public python-hidapi
+ (package
+ (name "python-hidapi")
+ (version "0.7.99.post21")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "hidapi" version))
+ (sha256
+ (base32
+ "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-configuration
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "setup.py"
+ (("'/usr/include/libusb-1.0'")
+ (string-append "'" (assoc-ref inputs "libusb")
+ "/include/libusb-1.0'")))
+ #t)))))
+ (inputs
+ `(("libusb" ,libusb)
+ ("eudev" ,eudev)))
+ (native-inputs
+ `(("python-cython" ,python-cython)))
+ (home-page "https://github.com/trezor/cython-hidapi")
+ (synopsis "Cython interface to hidapi")
+ (description "A Cython interface to the hidapi.")
+ ;; The library can be used under either of these licenses.
+ ;; TODO cython-hidapi DIY license.
+ (license (list gpl3 bsd-3))))
+
+(define-public python2-hidapi
+ (package-with-python2 python-hidapi))
Leo Famulari wrote 7 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 29850@debbugs.gnu.org)
20171226184414.GA1413@jasmine.lan
On Tue, Dec 26, 2017 at 12:03:19AM +0100, Danny Milosavljevic wrote:
Toggle quote (5 lines)
> * gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.

> + (synopsis "Cython interface to hidapi")
> + (description "A Cython interface to the hidapi.")

Please make it a complete English sentence:

This package provides a Cython interface to the HIDAPI library.

Otherwise LGTM!
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAlpCmHsACgkQJkb6MLrK
fwjBnw//ZVNekt0XOjY6Tbfv0LOJWCGgHk9qQ5FNlidnm2ezIpFQ3JtDjB4uoolf
VCajWTDZea0ee2vbde1rr9KnnIugFHG7a7N4uk8l7pR8/g1lSPnAa7Mk/oaOJLAI
qqZWPC/Ep+qYMflXiyuuPBIh8nWwGXlK4Gfwp3ANJtklPSnjw699shm0vAqYfAsD
jlbrm/J8ngIHXC3dCj2bXbxiHNv9IxTnOlkTslYc4F1UZwI6AqXtts++kTuuYnCH
k0ynPkzCC6b7EDyQjsolhI5oa9BaBuBBVEE0Oof6d1WVRESGiu8DK+aOwBcrubac
IlUpl20+7Z6Zwpkz65nj1sMtXfZFQYJWy3MRJ+EjX6O8aOwbafU4Bq/FV4n45yFj
8R4ZU6ZX92e6fyjff8fAY2dYIYbSSjX1xpw0caELty0r1+PaWKlxE+Czyfp7Po/z
rVCg6Cv21zo46/GZKrSE1cgsLcv5hinQWxW+9F7N6mdJT7QNqqEZKnbr95XSdqyB
FVOJVfnFYS3x7CeBQQ/V1pWThxdarRPoDPHowpk/v0naeDFdU7GkSJeqveSYBbHI
hPpblB9oh3e8n579+YpOTaBAosJnxJUp9KPKW4GUACrfqq8FSfaVgQnmkS3ROmh0
w2EHLtJYk1543eZ2dD27AzHT9zCWHuQC35/Pwb9wDQWWprJQoiQ=
=bik3
-----END PGP SIGNATURE-----


Danny Milosavljevic wrote 7 years ago
(name . Leo Famulari)(address . leo@famulari.name)(address . 29850@debbugs.gnu.org)
20171227012349.004bd308@scratchpost.org
On Tue, 26 Dec 2017 13:44:14 -0500
Leo Famulari <leo@famulari.name> wrote:

Toggle quote (10 lines)
> On Tue, Dec 26, 2017 at 12:03:19AM +0100, Danny Milosavljevic wrote:
> > * gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.
>
> > + (synopsis "Cython interface to hidapi")
> > + (description "A Cython interface to the hidapi.")
>
> Please make it a complete English sentence:
>
> This package provides a Cython interface to the HIDAPI library.

Okay.

What about the extra license?
Danny Milosavljevic wrote 7 years ago
[PATCH v2] gnu: Add python-hidapi.
(address . 29850@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20171227112711.12943-1-dannym@scratchpost.org
* gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.
---
gnu/packages/libusb.scm | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)

Toggle diff (68 lines)
diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index 31c7dfa44..7dd9a41eb 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -352,3 +352,63 @@ HID-Class devices.")
(license (list gpl3
bsd-3
(non-copyleft "file://LICENSE-orig.txt")))))
+
+(define-public python-hidapi
+ (package
+ (name "python-hidapi")
+ (version "0.7.99.post21")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "hidapi" version))
+ (sha256
+ (base32
+ "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
+ (modules '((guix build utils)))
+ (snippet
+ ;; Remove bundled libraries.
+ '(begin
+ (delete-file-recursively "hidapi")))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-configuration
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "setup.py"
+ (("'/usr/include/libusb-1.0'")
+ (string-append "'" (assoc-ref inputs "libusb")
+ "/include/libusb-1.0'"))
+ (("'/usr/include/hidapi'")
+ (string-append "'" (assoc-ref inputs "hidapi")
+ "/include/hidapi'")))
+ #t))
+ (replace 'build
+ (lambda _
+ ;; Necessary because python-build-system drops the arguments.
+ (invoke "python" "setup.py" "build" "--with-system-hidapi")))
+ (replace 'check
+ (lambda _
+ ;; Necessary because python-build-system drops the arguments.
+ (invoke "python" "setup.py" "test" "--with-system-hidapi")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Necessary because python-build-system drops the arguments.
+ (invoke "python" "setup.py" "install" "--with-system-hidapi"
+ (string-append "--prefix=" (assoc-ref outputs "out"))
+ "--single-version-externally-managed" "--root=/"))))))
+ (inputs
+ `(("hidapi" ,hidapi)
+ ("libusb" ,libusb)
+ ("eudev" ,eudev)))
+ (native-inputs
+ `(("python-cython" ,python-cython)))
+ (home-page "https://github.com/trezor/cython-hidapi")
+ (synopsis "Cython interface to hidapi")
+ (description "This package provides a Cython interface to @code{hidapi}.")
+ ;; The library can be used under either of these licenses.
+ ;; TODO Add cython-hidapi DIY license?
+ (license (list gpl3 bsd-3))))
+
+(define-public python2-hidapi
+ (package-with-python2 python-hidapi))
Leo Famulari wrote 7 years ago
Re: [bug#29850] [PATCH] gnu: Add python-hidapi.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 29850@debbugs.gnu.org)
20171227192024.GA21311@jasmine.lan
On Wed, Dec 27, 2017 at 01:23:49AM +0100, Danny Milosavljevic wrote:
Toggle quote (17 lines)
> On Tue, 26 Dec 2017 13:44:14 -0500
> Leo Famulari <leo@famulari.name> wrote:
>
> > On Tue, Dec 26, 2017 at 12:03:19AM +0100, Danny Milosavljevic wrote:
> > > * gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.
> >
> > > + (synopsis "Cython interface to hidapi")
> > > + (description "A Cython interface to the hidapi.")
> >
> > Please make it a complete English sentence:
> >
> > This package provides a Cython interface to the HIDAPI library.
>
> Okay.
>
> What about the extra license?

I would add it to the list of licenses in the license field using the
non-copyleft procedure. If you've never used non-copyleft, note that it
is a procedure that takes a URI and comment as arguments.
-----BEGIN PGP SIGNATURE-----

iQIyBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAlpD8ngACgkQJkb6MLrK
fwju/Q/2KVxZrZPwE0UhWMbY9ANQyDyDrwKPb8OTjqIwQLm3akcPgvZlC6B7s01I
mPSEbtAr1GRmiKJ/Y3S12Z9ANCgQ69nOWJKTyU08vpE0LFW540ylzHHwim5U6zwK
wLOn3C3/mW5UHNvQgp1CVLNgVgxjfOE/ngjBPfdJ2eVEvP7YM3hnepXxmvIgCadd
vSOmSqzp6lk3Vnw0F2bE9NEdTnFqkjvQJICdeqZk74jLrQ9J7TJyuuXD5swKx0tx
Y93hw8XXAT0fQGAbv304bbYSoEvB8D4RJA69iOlk7VWlpJoEWMJZYI/zH+PzRgOI
2DKp91Md1bXa3GBzwEpp6Ie3BqRIihxj4yXGE0OJgiaEUikY3BuH9PaPnwRgVJ0I
cGN+fZiN2KmU9gGfwhir0oEHLAzFu0kXTJRcabCxhq/bLh1CfJgujKh4edwVYf4u
LpFbMhHwlEyNd43U1eW0wSN8+sVRhifn4Dpq9b08cXTogR3lkijjSC91d/POdZ9v
5ILBltQNoovAZzJVm3pPT7Y9MQmE+p7kIidbNulUjCgsYDEBpF9SmFJzT3dvBA3C
STjL9zWZINyIGfMPZIB5beCZIUsxSjXkzBrVfncZFhH4PBPoEOSvfoIdFY3XyWTy
iH0d71cLbyZVZ+8RlepBWZTaQf5w5HIU2jLAtUDDq7fVhzML7w==
=NS37
-----END PGP SIGNATURE-----


Danny Milosavljevic wrote 7 years ago
[PATCH v3] gnu: Add python-hidapi.
(address . 29850@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20171227195351.10879-1-dannym@scratchpost.org
* gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.
---
gnu/packages/libusb.scm | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)

Toggle diff (70 lines)
diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index 31c7dfa44..b4db9e851 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -352,3 +352,65 @@ HID-Class devices.")
(license (list gpl3
bsd-3
(non-copyleft "file://LICENSE-orig.txt")))))
+
+(define-public python-hidapi
+ (package
+ (name "python-hidapi")
+ (version "0.7.99.post21")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (pypi-uri "hidapi" version))
+ (sha256
+ (base32
+ "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))
+ (modules '((guix build utils)))
+ (snippet
+ ;; Remove bundled libraries.
+ '(begin
+ (delete-file-recursively "hidapi")))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-configuration
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "setup.py"
+ (("'/usr/include/libusb-1.0'")
+ (string-append "'" (assoc-ref inputs "libusb")
+ "/include/libusb-1.0'"))
+ (("'/usr/include/hidapi'")
+ (string-append "'" (assoc-ref inputs "hidapi")
+ "/include/hidapi'")))
+ #t))
+ (replace 'build
+ (lambda _
+ ;; Necessary because python-build-system drops the arguments.
+ (invoke "python" "setup.py" "build" "--with-system-hidapi")))
+ (replace 'check
+ (lambda _
+ ;; Necessary because python-build-system drops the arguments.
+ (invoke "python" "setup.py" "test" "--with-system-hidapi")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Necessary because python-build-system drops the arguments.
+ (invoke "python" "setup.py" "install" "--with-system-hidapi"
+ (string-append "--prefix=" (assoc-ref outputs "out"))
+ "--single-version-externally-managed" "--root=/"))))))
+ (inputs
+ `(("hidapi" ,hidapi)
+ ("libusb" ,libusb)
+ ("eudev" ,eudev)))
+ (native-inputs
+ `(("python-cython" ,python-cython)))
+ (home-page "https://github.com/trezor/cython-hidapi")
+ (synopsis "Cython interface to hidapi")
+ (description "This package provides a Cython interface to @code{hidapi}.")
+ ;; The library can be used under either of these licenses.
+ ;; TODO Add cython-hidapi DIY license?
+ (license (list gpl3 bsd-3
+ (non-copyleft
+ "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt")))))
+
+(define-public python2-hidapi
+ (package-with-python2 python-hidapi))
Marius Bakke wrote 7 years ago
87tvwbdeac.fsf@fastmail.com
Hello!

Danny Milosavljevic <dannym@scratchpost.org> writes:

Toggle quote (2 lines)
> * gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables.

[...]

Toggle quote (12 lines)
> +(define-public python-hidapi
> + (package
> + (name "python-hidapi")
> + (version "0.7.99.post21")
> + (source
> + (origin
> + (method url-fetch)
> + (uri (pypi-uri "hidapi" version))
> + (sha256
> + (base32
> + "15ws59zdrxahf3k7z5rcrwc4jgv1307anif8ixm2cyb9ask1mgp0"))

Please re-indent the entire expression with emacs or ./etc/indent-code.el.

Toggle quote (6 lines)
> + (modules '((guix build utils)))
> + (snippet
> + ;; Remove bundled libraries.
> + '(begin
> + (delete-file-recursively "hidapi")))))

In absense of a consensus on unspecified return values, return #t here.

Toggle quote (29 lines)
> + (build-system python-build-system)
> + (arguments
> + `(#:phases
> + (modify-phases %standard-phases
> + (add-after 'unpack 'patch-configuration
> + (lambda* (#:key inputs #:allow-other-keys)
> + (substitute* "setup.py"
> + (("'/usr/include/libusb-1.0'")
> + (string-append "'" (assoc-ref inputs "libusb")
> + "/include/libusb-1.0'"))
> + (("'/usr/include/hidapi'")
> + (string-append "'" (assoc-ref inputs "hidapi")
> + "/include/hidapi'")))
> + #t))
> + (replace 'build
> + (lambda _
> + ;; Necessary because python-build-system drops the arguments.
> + (invoke "python" "setup.py" "build" "--with-system-hidapi")))
> + (replace 'check
> + (lambda _
> + ;; Necessary because python-build-system drops the arguments.
> + (invoke "python" "setup.py" "test" "--with-system-hidapi")))
> + (replace 'install
> + (lambda* (#:key outputs #:allow-other-keys)
> + ;; Necessary because python-build-system drops the arguments.
> + (invoke "python" "setup.py" "install" "--with-system-hidapi"
> + (string-append "--prefix=" (assoc-ref outputs "out"))
> + "--single-version-externally-managed" "--root=/"))))))

I don't think repeating the same comment thrice is necessary. Maybe
just add an XXX note at the top mentioning why we do this dance rather
than use python-build-system directly.

It would be good to extend python-build-system to support this however.
#:setuppy-flags? :)

Toggle quote (12 lines)
> + (inputs
> + `(("hidapi" ,hidapi)
> + ("libusb" ,libusb)
> + ("eudev" ,eudev)))
> + (native-inputs
> + `(("python-cython" ,python-cython)))
> + (home-page "https://github.com/trezor/cython-hidapi")
> + (synopsis "Cython interface to hidapi")
> + (description "This package provides a Cython interface to @code{hidapi}.")
> + ;; The library can be used under either of these licenses.
> + ;; TODO Add cython-hidapi DIY license?

I think this TODO can be removed, we have lots of "one-off" licenses
scattered throughout.

Toggle quote (4 lines)
> + (license (list gpl3 bsd-3
> + (non-copyleft
> + "https://github.com/trezor/cython-hidapi/blob/master/LICENSE-orig.txt")))))

The (non-copyleft ...) procedure takes an optional comment. This
license is short enough to fit, maybe we can just add the "whole" text?

No strong opinion. The rest LGTM!

Toggle quote (3 lines)
> +
> +(define-public python2-hidapi
> + (package-with-python2 python-hidapi))
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlpEF2sACgkQoqBt8qM6
VPpfCAgAmrL41OAb5+xWj9IYFP3dN57ahFLNeBUbTxEzOOWxxY7Zdms0tZvTckYn
6kP2ncaFGMFo83JAx9XRlXye7OvNgidOSJ0WXUUNoXW86iIWcWdLN6MjJsMHuxTl
v5wPYNfDFL6dOt9PETaIAMiqyfArquSFlWcTvyfX+ryWPo7k2rgdkSwXTXNohhiS
RAkYNU/4GAn6quhRJu+jO6aDOiwrqg+V6MuK3mXarpf949q1QM4us6RQkfDlVQA4
yDB4jNR9F5Y9E7Kj3blHHYnNcooApvYbPB91eOZrcje/7U8Y6gHIUbRtyGplgdDA
40/xnARxdS4MD+Eosl3UjzGTqpjCWA==
=T7Qf
-----END PGP SIGNATURE-----

Danny Milosavljevic wrote 7 years ago
(name . Marius Bakke)(address . mbakke@fastmail.com)(address . 29850-done@debbugs.gnu.org)
20171228084100.44a3f150@scratchpost.org
Hi Marius,

thanks for the review! Fixed these and pushed that patch to master.

Toggle quote (1 lines)
> It would be good to extend python-build-system to support this however.
#:setuppy-flags? :)

I agree. But I think Hartmut said that the arguments aren't necessarily the same for build, install and check. Let's see...
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 29850@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 29850
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help