* [Buildroot] [PATCH v2 1/1] package/python-hwdata: new package
@ 2023-03-13 21:34 Julien Olivain
2023-03-13 21:55 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2023-03-13 21:34 UTC (permalink / raw)
To: buildroot; +Cc: Julien Olivain, Asaf Kahlon, Thomas Petazzoni
Provides python interface to database stored in hwdata
package. It allows you to get human readable description of
USB and PCI devices.
https://github.com/xsuchy/python-hwdata
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Changes v1 -> v2:
- Add the LICENSE file from upstream git,
suggested by Thomas.
Patch tested on branch master at commit 61ba55e with commands:
make check-package
...
0 warnings generated
python3 -m flake8 \
support/testing/tests/package/sample_python_hwdata.py \
support/testing/tests/package/test_python_hwdata.py
[no-output]
support/testing/run-tests \
-d dl -o output_folder \
tests.package.test_python_hwdata
...
OK
---
DEVELOPERS | 3 ++
package/Config.in | 1 +
package/python-hwdata/Config.in | 12 ++++++
package/python-hwdata/python-hwdata.hash | 5 +++
package/python-hwdata/python-hwdata.mk | 23 +++++++++++
.../tests/package/sample_python_hwdata.py | 40 +++++++++++++++++++
.../tests/package/test_python_hwdata.py | 12 ++++++
7 files changed, 96 insertions(+)
create mode 100644 package/python-hwdata/Config.in
create mode 100644 package/python-hwdata/python-hwdata.hash
create mode 100644 package/python-hwdata/python-hwdata.mk
create mode 100644 support/testing/tests/package/sample_python_hwdata.py
create mode 100644 support/testing/tests/package/test_python_hwdata.py
diff --git a/DEVELOPERS b/DEVELOPERS
index 592c0e6b9c..b49491da7a 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1715,6 +1715,7 @@ F: package/ptm2human/
F: package/python-distro/
F: package/python-gnupg/
F: package/python-hkdf/
+F: package/python-hwdata/
F: package/python-magic-wormhole/
F: package/python-magic-wormhole-mailbox-server/
F: package/python-magic-wormhole-transit-relay/
@@ -1727,6 +1728,7 @@ F: package/z3/
F: package/zynaddsubfx/
F: support/testing/tests/package/sample_python_distro.py
F: support/testing/tests/package/sample_python_gnupg.py
+F: support/testing/tests/package/sample_python_hwdata.py
F: support/testing/tests/package/sample_python_pyalsa.py
F: support/testing/tests/package/sample_python_spake2.py
F: support/testing/tests/package/test_ddrescue.py
@@ -1748,6 +1750,7 @@ F: support/testing/tests/package/test_perftest.py
F: support/testing/tests/package/test_python_distro.py
F: support/testing/tests/package/test_python_gnupg.py
F: support/testing/tests/package/test_python_hkdf.py
+F: support/testing/tests/package/test_python_hwdata.py
F: support/testing/tests/package/test_python_magic_wormhole.py
F: support/testing/tests/package/test_python_pyalsa.py
F: support/testing/tests/package/test_python_spake2.py
diff --git a/package/Config.in b/package/Config.in
index f8ce83365e..0f8dab3e71 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1082,6 +1082,7 @@ menu "External python modules"
source "package/python-httplib2/Config.in"
source "package/python-huepy/Config.in"
source "package/python-humanize/Config.in"
+ source "package/python-hwdata/Config.in"
source "package/python-hyperframe/Config.in"
source "package/python-hyperlink/Config.in"
source "package/python-ibmiotf/Config.in"
diff --git a/package/python-hwdata/Config.in b/package/python-hwdata/Config.in
new file mode 100644
index 0000000000..923d0a7d8a
--- /dev/null
+++ b/package/python-hwdata/Config.in
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_PYTHON_HWDATA
+ bool "python-hwdata"
+ select BR2_PACKAGE_HWDATA # runtime
+ select BR2_PACKAGE_HWDATA_PCI_IDS
+ select BR2_PACKAGE_HWDATA_PNP_IDS
+ select BR2_PACKAGE_HWDATA_USB_IDS
+ help
+ Provides python interface to database stored in hwdata
+ package. It allows you to get human readable description of
+ USB and PCI devices.
+
+ https://github.com/xsuchy/python-hwdata
diff --git a/package/python-hwdata/python-hwdata.hash b/package/python-hwdata/python-hwdata.hash
new file mode 100644
index 0000000000..0c7ca31476
--- /dev/null
+++ b/package/python-hwdata/python-hwdata.hash
@@ -0,0 +1,5 @@
+# md5, sha256 from https://pypi.org/pypi/hwdata/json
+md5 dccf3b28d06fb9c6f56875e148356c24 hwdata-2.3.7.tar.gz
+sha256 9e5c96be38d9218ffde40834d4ca03344b8dfaed29c8c5afe0030125ea03db03 hwdata-2.3.7.tar.gz
+# Locally computed
+sha256 ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6 LICENSE
diff --git a/package/python-hwdata/python-hwdata.mk b/package/python-hwdata/python-hwdata.mk
new file mode 100644
index 0000000000..8eeec6efa8
--- /dev/null
+++ b/package/python-hwdata/python-hwdata.mk
@@ -0,0 +1,23 @@
+################################################################################
+#
+# python-hwdata
+#
+################################################################################
+
+PYTHON_HWDATA_VERSION = 2.3.7
+PYTHON_HWDATA_SOURCE = hwdata-$(PYTHON_HWDATA_VERSION).tar.gz
+PYTHON_HWDATA_SITE = https://files.pythonhosted.org/packages/15/26/f5bc1b42129fbcbd1c99c29714af1685fc89e2cf37680a9930d4fcac1808
+PYTHON_HWDATA_SETUP_TYPE = distutils
+PYTHON_HWDATA_LICENSE = GPL-2.0+
+PYTHON_HWDATA_LICENSE_FILES = LICENSE
+
+# There is no LICENSE file in the PyPi tarball, but it is available in
+# upstream git repository:
+PYTHON_HWDATA_EXTRA_DOWNLOADS = https://raw.githubusercontent.com/xsuchy/python-hwdata/python-hwdata-$(PYTHON_HWDATA_VERSION)-1/LICENSE
+
+define PYTHON_HWDATA_ADD_LICENSE_FILE
+ cp $(PYTHON_HWDATA_DL_DIR)/LICENSE $(@D)
+endef
+PYTHON_HWDATA_POST_EXTRACT_HOOKS += PYTHON_HWDATA_ADD_LICENSE_FILE
+
+$(eval $(python-package))
diff --git a/support/testing/tests/package/sample_python_hwdata.py b/support/testing/tests/package/sample_python_hwdata.py
new file mode 100644
index 0000000000..a13c08b32e
--- /dev/null
+++ b/support/testing/tests/package/sample_python_hwdata.py
@@ -0,0 +1,40 @@
+#! /usr/bin/env python3
+
+from hwdata import PCI, PNP, USB
+
+# Test PCI IDs
+pci_vendor_id = '1af4'
+pci_device_id = '1003'
+
+pci = PCI()
+
+pci_vendor = pci.get_vendor(pci_vendor_id)
+print("PCI Vendor: %s" % pci_vendor)
+assert (pci_vendor == "Red Hat, Inc.")
+
+pci_device = pci.get_device(pci_vendor_id, pci_device_id)
+print("PCI Device: %s" % pci_device)
+assert (pci_device == "Virtio console")
+
+# Test USB IDs
+usb_vendor_id = '1d6b'
+usb_device_id = '0001'
+
+usb = USB()
+
+usb_vendor = usb.get_vendor(usb_vendor_id)
+print("USB Vendor: %s" % usb_vendor)
+assert (usb_vendor == "Linux Foundation")
+
+usb_device = usb.get_device(usb_vendor_id, usb_device_id)
+print("USB Device: %s" % usb_device)
+assert (usb_device == "1.1 root hub")
+
+# Test PNP IDs
+pnp_id = 'RHT'
+
+pnp = PNP()
+
+pnp_vendor = pnp.get_vendor(pnp_id)
+print("PNP Vendor: %s" % pnp_vendor)
+assert (pnp_vendor == "Red Hat, Inc.")
diff --git a/support/testing/tests/package/test_python_hwdata.py b/support/testing/tests/package/test_python_hwdata.py
new file mode 100644
index 0000000000..7028d1dd59
--- /dev/null
+++ b/support/testing/tests/package/test_python_hwdata.py
@@ -0,0 +1,12 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonHwdata(TestPythonPackageBase):
+ __test__ = True
+ config = TestPythonPackageBase.config + \
+ """
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_HWDATA=y
+ """
+ sample_scripts = ["tests/package/sample_python_hwdata.py"]
+ timeout = 10
--
2.39.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [PATCH v2 1/1] package/python-hwdata: new package
2023-03-13 21:34 [Buildroot] [PATCH v2 1/1] package/python-hwdata: new package Julien Olivain
@ 2023-03-13 21:55 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-03-13 21:55 UTC (permalink / raw)
To: Julien Olivain; +Cc: Asaf Kahlon, buildroot
On Mon, 13 Mar 2023 22:34:39 +0100
Julien Olivain <ju.o@free.fr> wrote:
> Provides python interface to database stored in hwdata
> package. It allows you to get human readable description of
> USB and PCI devices.
>
> https://github.com/xsuchy/python-hwdata
>
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Changes v1 -> v2:
> - Add the LICENSE file from upstream git,
> suggested by Thomas.
Applied to master, thanks.
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-13 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-13 21:34 [Buildroot] [PATCH v2 1/1] package/python-hwdata: new package Julien Olivain
2023-03-13 21:55 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox