Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonasmalacofilho/8937fdd169d1068d8c95dcad7b6eb1aa to your computer and use it in GitHub Desktop.
Save jonasmalacofilho/8937fdd169d1068d8c95dcad7b6eb1aa to your computer and use it in GitHub Desktop.
From b8cadeeeeedb8b25211e5968ac681a48306d04f0 Mon Sep 17 00:00:00 2001
From: Jonas Malaco <[email protected]>
Date: Thu, 25 Jun 2020 12:29:03 -0300
Subject: [PATCH] python-hidapi: Check that the generated extension can be
imported
Due to, in the upstream project, a custom build process and the use of
unreleased hidapi APIs, python-hidapi has broken a couple of times in
the same number of months.
Some of this can be caught early by checking that the generated
extension(s) can be imported without errors:
python -c "import hid"
Add a check() function that does this, following the Python Packaging
Guidelines and using a `$PYTHONPATH`.
---
trunk/PKGBUILD | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index 7ee3066..59aeb65 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
@@ -24,7 +24,14 @@ build() {
--without-libusb --with-system-hidapi
}
-package_python-hidapi() {
+check() {
+ cd "$_pipname-$_pkgver"
+ local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
+
+ PYTHONPATH="$PWD/build/lib.linux-$CARCH-${python_version}" python -c "import hid"
+}
+
+package() {
cd $_pipname-$_pkgver
python setup.py install --root="$pkgdir" --optimize=1 --skip-build \
--
2.27.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment