~ruther/guix-local

ffa4ce6b723fa73d4d3fc496da0f9ad36d96c8b9 — Nicolas Graves 3 months ago b39ced1
gnu: python-hidapi: Switch to pyproject.

* gnu/packages/libusb.scm (python-hidapi):
[build-system]: Switch to pyproject-build-system.
[arguments]<#:phases>: Refresh phase 'patch-configuration.
Remove other phase replacements, use <#:configure-flags> instead.
<#:test-backend>: Set it.
[native-inputs]: Add python-setuptools.

Change-Id: I3ae1ed5b819a80abd3ec17a7fbe69d72a6e7a413
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
1 files changed, 17 insertions(+), 29 deletions(-)

M gnu/packages/libusb.scm
M gnu/packages/libusb.scm => gnu/packages/libusb.scm +17 -29
@@ 775,39 775,27 @@ HID-Class devices.")
       (modules '((guix build utils)))
       (snippet
        ;; Remove bundled libraries.
        '(begin
           (delete-file-recursively "hidapi")
           #t))))
    (build-system python-build-system)
        #~(begin
            (delete-file-recursively "hidapi")))))
    (build-system pyproject-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))
         ;; XXX Necessary because python-build-system drops the arguments.
         (replace 'build
           (lambda _
             (invoke "python" "setup.py" "build" "--with-system-hidapi")))
         (replace 'check
           (lambda _
             (invoke "python" "setup.py" "test" "--with-system-hidapi")))
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (invoke "python" "setup.py" "install" "--with-system-hidapi"
                     (string-append "--prefix=" (assoc-ref outputs "out"))
                     "--single-version-externally-managed" "--root=/"))))))
     (list
      #:test-backend #~'unittest
      #:configure-flags
      #~'(("--build-option" . "--with-system-hidapi"))
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'patch-configuration
            (lambda* (#:key inputs #:allow-other-keys)
              (substitute* "setup.py"
                (("/usr/include/libusb-1.0")
                 (search-input-directory inputs "include/libusb-1.0"))
                (("/usr/include/hidapi")
                 (search-input-directory inputs "include/hidapi"))))))))
    (inputs
     (list hidapi libusb eudev))
    (native-inputs
     (list python-cython pkg-config))
     (list pkg-config python-cython python-setuptools))
    (home-page "https://github.com/trezor/cython-hidapi")
    (synopsis "Cython interface to hidapi")
    (description "This package provides a Cython interface to @code{hidapi}.")