From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eU9sT-0006iH-Is for guix-patches@gnu.org; Wed, 27 Dec 2017 06:28:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eU9sQ-0002qd-NC for guix-patches@gnu.org; Wed, 27 Dec 2017 06:28:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:44486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eU9sQ-0002q3-Ir for guix-patches@gnu.org; Wed, 27 Dec 2017 06:28:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eU9sQ-0007BW-92 for guix-patches@gnu.org; Wed, 27 Dec 2017 06:28:02 -0500 Subject: [bug#29850] [PATCH v2] gnu: Add python-hidapi. Resent-Message-ID: From: Danny Milosavljevic Date: Wed, 27 Dec 2017 12:27:10 +0100 Message-Id: <20171227112711.12943-1-dannym@scratchpost.org> In-Reply-To: <20171226000319.6b5c478f@scratchpost.org> References: <20171226000319.6b5c478f@scratchpost.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 29850@debbugs.gnu.org * gnu/packages/libusb.scm (python-hidapi, python2-hidapi): New variables. --- gnu/packages/libusb.scm | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) 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))