From patchwork Wed Sep 20 10:05:27 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: 54069 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 1FBFD27BBE9; Wed, 20 Sep 2023 11:06:33 +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=unavailable 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 6BBB727BBE2 for ; Wed, 20 Sep 2023 11:06:30 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiu5p-0002mh-9k; Wed, 20 Sep 2023 06:06: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 1qiu5j-0002lt-54 for guix-patches@gnu.org; Wed, 20 Sep 2023 06:05:56 -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 1qiu5h-0004HR-KE for guix-patches@gnu.org; Wed, 20 Sep 2023 06:05:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qiu5q-00048j-UG for guix-patches@gnu.org; Wed, 20 Sep 2023 06:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65911] [PATCH v1 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, 20 Sep 2023 10:06:02 +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.169520436015883 (code B ref 65911); Wed, 20 Sep 2023 10:06:02 +0000 Received: (at 65911) by debbugs.gnu.org; 20 Sep 2023 10:06:00 +0000 Received: from localhost ([127.0.0.1]:58404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiu5n-000484-Dm for submit@debbugs.gnu.org; Wed, 20 Sep 2023 06:05:59 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:44299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiu5f-00047G-Eo for 65911@debbugs.gnu.org; Wed, 20 Sep 2023 06:05:53 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40479f8325fso59259385e9.1 for <65911@debbugs.gnu.org>; Wed, 20 Sep 2023 03:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundationdevices.com; s=google; t=1695204336; x=1695809136; 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=AEY39Nzynfb96WbQrYK1G+3rd70MLBmk3GrA+wuIFqUsS+d1DUZF1/wfqN+BhcL/Xw wc0VDRbmJYsjxEHiC2fAKq04UIlVxfpz5U4NZiM6YXw5TIKHSCCab45WlSoVvvA4UdEY 7t7tGgMVL7JTTvay0NixE46/Bg7MAlCx7wBGT0zcDtLZ2lhHslpo671EAK+yD1DB1V98 3KsbQpxFypEVBDcabl7OnRnmJtw5ldJjEgb2ckJDn+KVEZyzNEy1x4ZhdXTT6HoVPmrp awgsWBaWZTrItR/Bdh0fT7nOyQ1mOOVD2bTkVPAYTo1EaxmcQwbhd/Oy2MSPVELC/e1j gpeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695204336; x=1695809136; 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=R5pO0JEXe7vYbSk7UUSJ5Woz3cfW9Wtrz4FDgPqUZMSEKVWtHPmfePWdJUNS92fktd kr6rOcTz5Ln6r/zeXYwipzkWqfWJ8aOHr2TBlDPZOfwO633ECRmoB4b5HSzL2jiQUbqf uJ9NnG8ywX5/2ohgJ0LunwIJoxQnxkWqTXbABgJ9YvRarKZX8nfs8o59cxdoCas24SDV ebTr6gjj+SyCUi32KWsTpAk91pJJ6kwIKrI4lDiX9qlS4phegTDEgBLrZPUA7DOdersC 0R9k/RNMuzhknN4KxncmFNbbCuBfwMnBjNQ15Qq0qNAkYYNL3Cmsh9IJ96hWPGVm8L4A czhA== X-Gm-Message-State: AOJu0Yz6hMzi3RO3oGRSMtp8MfE1FJUbpM+Ey2UUBAna0EPNLz7ZeYUq MdiMlitkd5onvacP1F0Zas67Su84Rg2mSWoImlHA6g== X-Google-Smtp-Source: AGHT+IH9KhuxHpCdW/rhjkyR2VtP4WNEqJEvwh35J7TZUXRa7cJoqPYuLBqDAsRqIfR+7k7tGDYY9Q== X-Received: by 2002:a7b:cd08:0:b0:3ff:233f:2cfb with SMTP id f8-20020a7bcd08000000b003ff233f2cfbmr1926012wmj.23.1695204335947; Wed, 20 Sep 2023 03:05:35 -0700 (PDT) Received: from omen15.home ([89.131.29.87]) by smtp.gmail.com with ESMTPSA id y20-20020a05600c20d400b003fefaf299b6sm1496927wmm.38.2023.09.20.03.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 03:05:35 -0700 (PDT) Date: Wed, 20 Sep 2023 12:05:27 +0200 Message-Id: <20230920100528.1217339-3-jean@foundationdevices.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230920100528.1217339-1-jean@foundationdevices.com> References: <20230920100528.1217339-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