All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod v2][PATCH v2 0/5] bindings: implement python bindings for libgpiod v2
@ 2022-06-28  8:42 Bartosz Golaszewski
  2022-06-28  8:42 ` [libgpiod v2][PATCH v2 1/5] bindings: python: remove old version Bartosz Golaszewski
                   ` (5 more replies)
  0 siblings, 6 replies; 35+ messages in thread
From: Bartosz Golaszewski @ 2022-06-28  8:42 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Darrien,
	Viresh Kumar, Jiri Benc, Joel Savitz
  Cc: linux-gpio, Bartosz Golaszewski

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.

v1 -> v2:
- all methods now accept keyword arguments even for mandatory positional ones
- added a global request_lines() function that enables easy one-liner liner
  requests
- improve and unify the pydoc format
- many smaller tweaks and fixes

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                        |  606 ++++
 bindings/python/edge-event-buffer.c           |  330 ++
 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                 | 1373 +++++++++
 bindings/python/line-info.c                   |  286 ++
 bindings/python/line-request.c                |  803 +++++
 bindings/python/line.c                        |  239 ++
 bindings/python/module.c                      |  557 ++++
 bindings/python/module.h                      |   58 +
 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    |  279 ++
 .../python/tests/cases/tests_info_event.py    |  135 +
 .../python/tests/cases/tests_line_config.py   |  254 ++
 .../python/tests/cases/tests_line_info.py     |   90 +
 .../python/tests/cases/tests_line_request.py  |  345 +++
 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, 7517 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


^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2022-07-08 15:58 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28  8:42 [libgpiod v2][PATCH v2 0/5] bindings: implement python bindings for libgpiod v2 Bartosz Golaszewski
2022-06-28  8:42 ` [libgpiod v2][PATCH v2 1/5] bindings: python: remove old version Bartosz Golaszewski
2022-06-28  8:42 ` [libgpiod v2][PATCH v2 2/5] bindings: python: enum: add a piece of common code for using python's enums from C Bartosz Golaszewski
2022-06-28  8:42 ` [libgpiod v2][PATCH v2 3/5] bindings: python: add examples for v2 API Bartosz Golaszewski
2022-06-28  8:42 ` [libgpiod v2][PATCH v2 4/5] bindings: python: add tests " Bartosz Golaszewski
2022-07-05  2:08   ` Kent Gibson
2022-07-07 10:17     ` Bartosz Golaszewski
2022-07-07 12:22       ` Kent Gibson
2022-06-28  8:42 ` [libgpiod v2][PATCH v2 5/5] bindings: python: add the implementation " Bartosz Golaszewski
2022-06-30  2:25   ` Kent Gibson
2022-06-30  6:54     ` Bartosz Golaszewski
2022-06-30  8:14       ` Kent Gibson
2022-06-30  8:38         ` Kent Gibson
2022-07-01  6:07           ` Kent Gibson
2022-07-01  7:21             ` Bartosz Golaszewski
2022-07-01  7:26               ` Kent Gibson
2022-07-01  7:29                 ` Bartosz Golaszewski
2022-07-01  7:33                   ` Kent Gibson
2022-07-01  8:02                     ` Kent Gibson
2022-07-01  8:18                       ` Bartosz Golaszewski
2022-07-01  8:32                         ` Bartosz Golaszewski
2022-07-01  8:52                           ` Kent Gibson
2022-07-01  9:28                             ` Bartosz Golaszewski
2022-07-01  8:32                         ` Kent Gibson
2022-07-05  2:09   ` Kent Gibson
2022-07-07 12:19     ` Bartosz Golaszewski
2022-07-07 13:09       ` Kent Gibson
2022-07-07 20:09         ` Bartosz Golaszewski
2022-07-08  1:38           ` Kent Gibson
2022-07-08  9:49             ` Bartosz Golaszewski
2022-07-08 10:56               ` Kent Gibson
2022-07-08 11:28                 ` Bartosz Golaszewski
2022-07-08 15:26                   ` Bartosz Golaszewski
2022-07-08 15:58                     ` Kent Gibson
2022-06-28  8:47 ` [libgpiod v2][PATCH v2 0/5] bindings: implement python bindings for libgpiod v2 Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.