1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Files
libgpiod/docs/python_api.rst
Vincent Fazio c9378d6c63 bindings: python: support free-threaded CPython
PEP 703 [0] discusses making the GIL optional in certain builds of the
CPython interpreter.

This build option was available experiementally in Python 3.13 but has
since been stabilized in Python 3.14 per PEP 779 [1].

According to the porting guide [2], there is no strict requirement that
C extensions must be thread-safe.

Experiments have shown that no logic changes are required if callers
use sychronization mechanisms provided by the Python standard library.

The documentation has been updated to call this out specifically using
terminology from the porting guide [3].

[0]: https://peps.python.org/pep-0703/
[1]: https://peps.python.org/pep-0779/
[2]: https://py-free-threading.github.io/porting/#define-and-document-thread-safety-guarantees
[3]: https://py-free-threading.github.io/documentation-principles/#free-threading-terminology

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Link: https://patch.msgid.link/20260527215922.18678-3-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
2026-05-28 10:59:30 +02:00

1.4 KiB

libgpiod Python bindings API

The libgpiod Python bindings provide an interface to control and interact with GPIO (General-Purpose Input/Output) lines on Linux systems using the libgpiod library. The Python bindings allow developers to manage GPIO pins easily through Python scripts, enabling tasks such as reading input values, setting outputs, monitoring events, and configuring more fine-grained pin options.

The Python bindings, much like the C API they wrap, are not thread-safe and do require external synchronization by the caller to serialize access to objects shared across threads.

The bindings support both GIL-enabled and free-threaded CPython interpreters.

Note

Python bindings require python3 support and libpython development files for building from sources.

python_chip python_chip_info python_exceptions python_line python_line_info python_info_event python_edge_event python_line_settings python_line_request python_misc

Note

Python bindings can be installed from https://pypi.org/ with pip by running pip install gpiod.