From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Darrien <darrien@freenet.de>,
Viresh Kumar <viresh.kumar@linaro.org>, Jiri Benc <jbenc@upir.cz>,
Joel Savitz <joelsavitz@gmail.com>
Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [libgpiod v2][PATCH 0/5] bindings: implement python bindings for libgpiod v2
Date: Wed, 25 May 2022 16:06:59 +0200 [thread overview]
Message-ID: <20220525140704.94983-1-brgl@bgdev.pl> (raw)
This series adds python bindings for libgpiod v2. The series is split
into several patches for easier review.
In general the python bindings follow what we did for C++ in terms of class
layout except that we leverage python's flexibility to reduce the number of
method variants by allowing different types of arguments.
Because python doesn't have RAII, unlike C++, we provide a module-level
request_lines() helper as gpiod.Chip(path).request_lines(...) one-liner
could lead to the chip left dangling even after the last reference is
dropped.
Because python forces us to dynamically allocate objects all the time even
for fundamental types (which are also immutable) there's no point in trying
to make the EdgeEventBuffer avoid copying the events like we did in C++
for better performance. Python simply isn't designed around speed.
Bartosz Golaszewski (5):
bindings: python: remove old version
bindings: python: enum: add a piece of common code for using python's
enums from C
bindings: python: add examples for v2 API
bindings: python: add tests for v2 API
bindings: python: add the implementation for v2 API
bindings/python/.gitignore | 1 +
bindings/python/Makefile.am | 19 +-
bindings/python/chip-info.c | 126 +
bindings/python/chip.c | 552 ++++
bindings/python/edge-event-buffer.c | 301 ++
bindings/python/edge-event.c | 191 ++
bindings/python/enum/Makefile.am | 9 +
bindings/python/enum/enum.c | 208 ++
bindings/python/enum/enum.h | 24 +
bindings/python/examples/gpiodetect.py | 13 +-
bindings/python/examples/gpiofind.py | 12 +-
bindings/python/examples/gpioget.py | 28 +-
bindings/python/examples/gpioinfo.py | 39 +-
bindings/python/examples/gpiomon.py | 53 +-
bindings/python/examples/gpioset.py | 36 +-
bindings/python/exception.c | 182 ++
bindings/python/gpiodmodule.c | 2662 -----------------
bindings/python/info-event.c | 175 ++
bindings/python/line-config.c | 1338 +++++++++
bindings/python/line-info.c | 286 ++
bindings/python/line-request.c | 713 +++++
bindings/python/line.c | 239 ++
bindings/python/module.c | 281 ++
bindings/python/module.h | 57 +
bindings/python/request-config.c | 320 ++
bindings/python/tests/Makefile.am | 15 +-
bindings/python/tests/cases/__init__.py | 12 +
bindings/python/tests/cases/tests_chip.py | 157 +
.../python/tests/cases/tests_chip_info.py | 59 +
.../python/tests/cases/tests_edge_event.py | 274 ++
.../python/tests/cases/tests_info_event.py | 135 +
.../python/tests/cases/tests_line_config.py | 250 ++
.../python/tests/cases/tests_line_info.py | 90 +
.../python/tests/cases/tests_line_request.py | 295 ++
bindings/python/tests/cases/tests_misc.py | 53 +
.../tests/cases/tests_request_config.py | 77 +
bindings/python/tests/gpiod_py_test.py | 827 +----
bindings/python/tests/gpiomockupmodule.c | 309 --
bindings/python/tests/gpiosimmodule.c | 434 +++
configure.ac | 3 +-
40 files changed, 6973 insertions(+), 3882 deletions(-)
create mode 100644 bindings/python/.gitignore
create mode 100644 bindings/python/chip-info.c
create mode 100644 bindings/python/chip.c
create mode 100644 bindings/python/edge-event-buffer.c
create mode 100644 bindings/python/edge-event.c
create mode 100644 bindings/python/enum/Makefile.am
create mode 100644 bindings/python/enum/enum.c
create mode 100644 bindings/python/enum/enum.h
create mode 100644 bindings/python/exception.c
delete mode 100644 bindings/python/gpiodmodule.c
create mode 100644 bindings/python/info-event.c
create mode 100644 bindings/python/line-config.c
create mode 100644 bindings/python/line-info.c
create mode 100644 bindings/python/line-request.c
create mode 100644 bindings/python/line.c
create mode 100644 bindings/python/module.c
create mode 100644 bindings/python/module.h
create mode 100644 bindings/python/request-config.c
create mode 100644 bindings/python/tests/cases/__init__.py
create mode 100644 bindings/python/tests/cases/tests_chip.py
create mode 100644 bindings/python/tests/cases/tests_chip_info.py
create mode 100644 bindings/python/tests/cases/tests_edge_event.py
create mode 100644 bindings/python/tests/cases/tests_info_event.py
create mode 100644 bindings/python/tests/cases/tests_line_config.py
create mode 100644 bindings/python/tests/cases/tests_line_info.py
create mode 100644 bindings/python/tests/cases/tests_line_request.py
create mode 100644 bindings/python/tests/cases/tests_misc.py
create mode 100644 bindings/python/tests/cases/tests_request_config.py
delete mode 100644 bindings/python/tests/gpiomockupmodule.c
create mode 100644 bindings/python/tests/gpiosimmodule.c
--
2.34.1
next reply other threads:[~2022-05-25 14:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 14:06 Bartosz Golaszewski [this message]
2022-05-25 14:07 ` [libgpiod v2][PATCH 1/5] bindings: python: remove old version Bartosz Golaszewski
2022-05-25 14:07 ` [libgpiod v2][PATCH 2/5] bindings: python: enum: add a piece of common code for using python's enums from C Bartosz Golaszewski
2022-05-25 14:07 ` [libgpiod v2][PATCH 3/5] bindings: python: add examples for v2 API Bartosz Golaszewski
2022-06-03 12:46 ` Kent Gibson
2022-06-04 2:41 ` Kent Gibson
2022-06-06 10:14 ` Andy Shevchenko
2022-06-07 1:52 ` Kent Gibson
2022-06-07 10:43 ` Andy Shevchenko
2022-06-08 15:39 ` Bartosz Golaszewski
2022-06-09 4:49 ` Kent Gibson
2022-06-09 8:42 ` Bartosz Golaszewski
2022-06-09 13:21 ` Jiri Benc
2022-06-09 16:06 ` Bartosz Golaszewski
2022-06-10 4:23 ` Kent Gibson
2022-06-10 6:57 ` Bartosz Golaszewski
2022-05-25 14:07 ` [libgpiod v2][PATCH 4/5] bindings: python: add tests " Bartosz Golaszewski
2022-05-25 14:07 ` [libgpiod v2][PATCH 5/5] bindings: python: add the implementation " Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220525140704.94983-1-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=andriy.shevchenko@linux.intel.com \
--cc=darrien@freenet.de \
--cc=jbenc@upir.cz \
--cc=joelsavitz@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).