From patchwork Wed Sep 13 09:55:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Pierre De Jesus DIAZ X-Patchwork-Id: 53783 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5C67E27BBE2; Wed, 13 Sep 2023 10:57:30 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AC4F927BBEA for ; Wed, 13 Sep 2023 10:57:28 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgMcH-00036i-JT; Wed, 13 Sep 2023 05:57:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgMcE-00034p-Fb for guix-patches@gnu.org; Wed, 13 Sep 2023 05:56:58 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgMcE-0002oM-61 for guix-patches@gnu.org; Wed, 13 Sep 2023 05:56:58 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgMcJ-0008PT-9U for guix-patches@gnu.org; Wed, 13 Sep 2023 05:57:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65911] [PATCH 3/4] gnu: python-pyusb: Add libusb-compat backend. Resent-From: Jean-Pierre De Jesus DIAZ Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 13 Sep 2023 09:57:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65911 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65911@debbugs.gnu.org Cc: Jean-Pierre De Jesus DIAZ Received: via spool by 65911-submit@debbugs.gnu.org id=B65911.169459898232256 (code B ref 65911); Wed, 13 Sep 2023 09:57:03 +0000 Received: (at 65911) by debbugs.gnu.org; 13 Sep 2023 09:56:22 +0000 Received: from localhost ([127.0.0.1]:60857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgMbd-0008O6-TR for submit@debbugs.gnu.org; Wed, 13 Sep 2023 05:56:22 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:45239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgMbY-0008NQ-HC for 65911@debbugs.gnu.org; Wed, 13 Sep 2023 05:56:17 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-401da71b83cso74480185e9.2 for <65911@debbugs.gnu.org>; Wed, 13 Sep 2023 02:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundationdevices.com; s=google; t=1694598965; x=1695203765; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3WmwWDNs8CuejHUN7rlzKMqwPQNpS7WuhsiYmPQlJOo=; b=dovMy5zNeKBxja14bfFTsggjgPRXTA92bZMahNGEB/cYj/vpuGRqXiJ3OtEPli6xWR hJxd+a5xAgkdRn6cyP564zjCOdAD4D72bGQVAljCUKQ+Qes5JdIStzMyErqO+/rQa2oh usbiE24ZT8UcIzrWbcFxDFVUncnDpywrWrtP9U5jUs28P0Cb9NftIbry4mCKt7NWe+9G y2ki8jXd/y2hfdivskxugKk5wXNRqCAEiaNgCFX2Kd5oyuscDSdi94kyxtHCLaFvvyp6 Str8XJ054vKn1VVMBgRxqco1p0MKziAri9TvRK+fIAuXiwr5uwiEXKB9WomhPYQhQY/N Pq8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694598965; x=1695203765; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3WmwWDNs8CuejHUN7rlzKMqwPQNpS7WuhsiYmPQlJOo=; b=AckvMhnvLS8tI9O5/mhkBCpOrOCC1KxwpguBXSANIZ/9DPs0YZ9MJroXPnFfJOYPbC Slof6b6ryCH8TIr21beZ7aLK+LJ21pwXWQ5WUurzJ0TIKH2IOlsoSbIdFpERZW/s6/Mh 6HP/X1I1HPFDAVm0DuYZ/YoJLxDlPc2yHf5Fov2DDC17RQiev2ukEa7H4D4RodfEXf2I w684X+5hIpiygPGs+iDxHfrAf7HSDQXVd65TNKlTLgBlIIvcyn+uIYqp73BguwLmxMJ0 Bchw1Y+ILhpXnRr9vPfUw46/6RvGlLX05Ld+CAVnRILSqDgsHH7xXNHwGQFHysJQeyGA G1dA== X-Gm-Message-State: AOJu0YydfD4hGT2siXejkrBb+weNevvL5tPOOFxvjEFglRVjw30Dl9zo Onv2yHi84yV3rn34oltQhCcGm7hCbbLPBEKVnjn4vA== X-Google-Smtp-Source: AGHT+IFLxKeMuDaEDN5kx7ISzMWmFYdEjndYuu2x5oii5xZkoTVqJ2en9TkpqDxrulqmoOVG0ZVvaQ== X-Received: by 2002:a1c:4c09:0:b0:401:bf87:9898 with SMTP id z9-20020a1c4c09000000b00401bf879898mr1840217wmf.25.1694598965389; Wed, 13 Sep 2023 02:56:05 -0700 (PDT) Received: from omen15.home ([89.131.29.87]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003fe2b081661sm1577675wmc.30.2023.09.13.02.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:56:05 -0700 (PDT) Date: Wed, 13 Sep 2023 11:55:58 +0200 Message-Id: <20230913095559.12676-3-jean@foundationdevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230913095559.12676-1-jean@foundationdevices.com> References: <20230913095559.12676-1-jean@foundationdevices.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jean-Pierre De Jesus DIAZ X-ACL-Warn: , Jean-Pierre De Jesus DIAZ via Guix-patches X-Patchwork-Original-From: Jean-Pierre De Jesus DIAZ via Guix-patches via From: Jean-Pierre De Jesus DIAZ Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/libusb.scm (python-pyusb) : Do not hard-code libusb1 library for all back-ends, and allow to use libusb0 as a back-end. Also enabled tests as the package does have a test suite. * gnu/packages/libusb.scm (python-pyusb) : Add libusb-compat. Signed-off-by: Jean-Pierre De Jesus DIAZ --- gnu/packages/libusb.scm | 52 +++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm index 469882e871..d15e561668 100644 --- a/gnu/packages/libusb.scm +++ b/gnu/packages/libusb.scm @@ -288,28 +288,56 @@ (define-public python-pyusb "1fg7knfzybzija2b01pzrzhzsj989scl12sb2ra4f503l8279k54")))) (build-system python-build-system) (arguments - (list #:tests? #f ; no tests - #:modules '((srfi srfi-1) + (list #:modules '((srfi srfi-1) (srfi srfi-26) (guix build utils) (guix build python-build-system)) #:phases #~(modify-phases %standard-phases + ;; Repurpose the candidates parameter to be the path to the + ;; library, then on each backend we substitute the candidates + ;; with the full path to the .so library or with None if not + ;; supported. + ;; + ;; While most applications could use a single back-end this + ;; library allows to manually select the back-end so it is + ;; appropriate to provide as much back-ends as possible. (add-after 'unpack 'fix-libusb-reference (lambda* (#:key inputs #:allow-other-keys) - (substitute* "usb/libloader.py" - (("lib = locate_library\\(candidates, find_library\\)") - (string-append - "lib = \"" - (find (negate symbolic-link?) - (find-files (assoc-ref inputs "libusb") - "^libusb-.*\\.so\\..*")) - "\"")))))))) - + (let ((libusb0 (find + (negate symbolic-link?) + (find-files (assoc-ref inputs "libusb-compat") + "^libusb-.*\\.so\\..*"))) + (libusb1 (find + (negate symbolic-link?) + (find-files (assoc-ref inputs "libusb") + "^libusb-.*\\.so\\..*")))) + (substitute* "usb/libloader.py" + (("lib = locate_library\\(candidates, find_library\\)") + "lib = candidates")) + (substitute* "usb/backend/libusb0.py" + (("\\('usb-0\\.1', 'usb', 'libusb0'\\)") + (format #f "~s" libusb0))) + (substitute* "usb/backend/libusb1.py" + (("\\('usb-1\\.0', 'libusb-1\\.0', 'usb'\\)") + (format #f "~s" libusb1))) + ;; FIXME: OpenUSB is not packaged for GNU Guix. + (substitute* "usb/backend/openusb.py" + (("\\('openusb',\\)") "None"))))) + ;; Note: tests seems to succeed with libusb-compat as libusb + ;; fails because it doesn't have a usbfs present in the build + ;; environment. + (replace 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (with-directory-excursion "tests" + (setenv "PYUSB_DEBUG" "debug") + (setenv "LIBUSB_DEBUG" "4") + (invoke "python" "testall.py")))))))) (native-inputs (list python-setuptools-scm)) (inputs - (list libusb)) + (list libusb libusb-compat)) (home-page "https://pyusb.github.io/pyusb/") (synopsis "Python bindings to the libusb library") (description