diff mbox series

[meta-python,3/3] python3-gpiod: new package

Message ID 20230208152541.136848-4-brgl@bgdev.pl
State Under Review
Headers show
Series libgpiod: add support for libgpiod v2 | expand

Commit Message

Bartosz Golaszewski Feb. 8, 2023, 3:25 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Add a recipe for libgpiod v2 python bindings. This is a release
candidate but once the proper v2.0 is released, it will be made public
on pypi and the recipe modified accordingly.

As libgpiod python bindings now use setuptools and not make, we can
separate the recipe from the rest of the library.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 .../packagegroups/packagegroup-meta-python.bb |  1 +
 .../python/python3-gpiod/run-ptest            | 15 +++++++
 .../python/python3-gpiod_2.0-rc1.bb           | 45 +++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod/run-ptest
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod_2.0-rc1.bb
diff mbox series

Patch

diff --git a/meta-python/recipes-core/packagegroups/packagegroup-meta-python.bb b/meta-python/recipes-core/packagegroups/packagegroup-meta-python.bb
index 2275ccd6c..2428674c4 100644
--- a/meta-python/recipes-core/packagegroups/packagegroup-meta-python.bb
+++ b/meta-python/recipes-core/packagegroups/packagegroup-meta-python.bb
@@ -157,6 +157,7 @@  RDEPENDS:packagegroup-meta-python3 = "\
     python3-gmqtt \
     python3-gnupg \
     python3-google-api-python-client \
+    python3-gpiod \
     python3-gpsd-py3 \
     python3-graphviz \
     python3-greenlet \
diff --git a/meta-python/recipes-devtools/python/python3-gpiod/run-ptest b/meta-python/recipes-devtools/python/python3-gpiod/run-ptest
new file mode 100644
index 000000000..bf1244b07
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-gpiod/run-ptest
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+
+cd $(dirname "$(readlink -f "$0")")
+
+# python3-gpiod uses gpio-sim - a configfs-based testing module. We need to
+# make sure configfs is mounted before running any tests.
+modprobe configfs
+mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config
+
+python3 -m gpiod-test -v > ./python3-gpiod.out 2>&1
+if [ $? -ne 0 ]; then
+	echo "FAIL: python3-gpiod"
+else
+	echo "PASS: python3-gpiod"
+fi
diff --git a/meta-python/recipes-devtools/python/python3-gpiod_2.0-rc1.bb b/meta-python/recipes-devtools/python/python3-gpiod_2.0-rc1.bb
new file mode 100644
index 000000000..a05cc3619
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-gpiod_2.0-rc1.bb
@@ -0,0 +1,45 @@ 
+SUMMARY = "Python bindings for libgpiod."
+AUTHOR = "Bartosz Golaszewski <brgl@bgdev.pl>"
+
+LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later & CC-BY-SA-4.0"
+LIC_FILES_CHKSUM = " \
+    file://../../LICENSES/GPL-2.0-or-later.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
+    file://../../LICENSES/LGPL-2.1-or-later.txt;md5=4b54a1fd55a448865a0b32d41598759d \
+    file://../../LICENSES/CC-BY-SA-4.0.txt;md5=fba3b94d88bfb9b81369b869a1e9a20f \
+"
+
+require recipes-support/libgpiod/libgpiod-src.inc
+
+SRC_URI += "file://run-ptest"
+
+SRC_URI[sha256sum] = "64a718e8f8e022afc1880bae0b6ddc874fca1ce1bf8a2ac88bab4ccca6b66a1e"
+S = "${WORKDIR}/libgpiod-2.0/bindings/python"
+
+inherit setuptools3 ptest
+
+DEPENDS += "libgpiod"
+RDEPENDS:${PN} += "libgpiod (>= 2.0)"
+RDEPENDS:${PN}-ptest += "python3-setuptools"
+
+export GPIOD_WITH_TESTS = "${@bb.utils.contains("PTEST_ENABLED", "1", "1", "0", d)}"
+PTEST_CFLAGS = "${@bb.utils.contains("PTEST_ENABLED", "1", "-I../../tests/gpiosim", "", d)}"
+# Setuptools store full filesystem paths in DWARF files. Map them to './' to
+# avoid QA warnings.
+export CFLAGS = "${PTEST_CFLAGS} -fdebug-prefix-map=${B}=./"
+
+do_install:append() {
+    # Python setuptools have an issue where they install C extensions even if
+    # they're not in the list of packages to be packaged. This is how the test
+    # extensions end up being installed. Remove them here.
+    rm -rf ${D}${PYTHON_SITEPACKAGES_DIR}/tests/
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/gpiod-test/gpiosim
+    install -d ${D}${PTEST_PATH}/gpiod-test/procname
+    install -m 0644 ${B}/tests/*.py ${D}${PTEST_PATH}/gpiod-test/
+    install -m 0644 ${B}/build/lib*/tests/gpiosim/_ext* ${D}${PTEST_PATH}/gpiod-test/gpiosim
+    install -m 0644 ${B}/tests/gpiosim/*.py ${D}${PTEST_PATH}/gpiod-test/gpiosim
+    install -m 0644 ${B}/build/lib*/tests/procname/_ext* ${D}${PTEST_PATH}/gpiod-test/procname
+    install -m 0644 ${B}/tests/procname/*.py ${D}${PTEST_PATH}/gpiod-test/procname
+}