Python bindings for libgpiod
Project description
gpiod
These are the official Python bindings for libgpiod.
The gpiod library has been vendored into this package for your convenience and this version of gpiod is independent from your system package.
Binary wheels are not provided. The source package requires python3-dev.
Rationale
The new character device interface guarantees all allocated resources are freed after closing the device file descriptor and adds several new features that are not present in the obsolete sysfs interface (like event polling, setting/reading multiple values at once or open-source and open-drain GPIOs).
Unfortunately interacting with the linux device file can no longer be done using only standard command-line tools. This is the reason for creating a library encapsulating the cumbersome, ioctl-based kernel-userspace interaction in a set of convenient functions and opaque data structures.
Breaking Changes
As of v2.0.2 we have replaced the unofficial, pure-Python "gpiod". The official gpiod is not backwards compatible.
You should ensure you specify at least v2.0.2 for the official API. Versions 1.5.4 and prior are the deprecated, unofficial, pure-Python bindings.
Installing
You will need python3-dev
, on Debian/Ubuntu you can install this with:
sudo apt install python3-dev
And then install gpiod with:
pip install gpiod
You can optionally depend upon your system gpiod by installing with:
LINK_SYSTEM_LIBGPIOD=1 pip install gpiod
If you still need the deprecated pure-Python bindings, install with:
pip install gpiod==1.5.4
Examples
Check a GPIO chip character device exists:
import gpiod
gpiod.is_gpiochip_device("/dev/gpiochip0")
Get information about a GPIO chip character device:
import gpiod
with gpiod.Chip("/dev/gpiochip0") as chip:
info = chip.get_info()
print(f"{info.name} [{info.label}] ({info.num_lines} lines)")
Blink an LED, or toggling a GPIO line:
import time
from gpiod.line import Direction, Value
LINE = 5
with gpiod.request_lines(
"/dev/gpiochip0",
consumer="blink-example",
config={
LINE: gpiod.LineSettings(
direction=Direction.OUTPUT, output_value=Value.ACTIVE
)
},
) as request:
while True:
request.set_value(LINE, Value.ACTIVE)
time.sleep(1)
request.set_value(LINE, Value.INACTIVE)
time.sleep(1)
Testing
The test suite for the python bindings can be run by calling:
make python-tests-run
from the libgpiod/bindings/python
directory as root (necessary to be able
to create the gpio-sims used for testing).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file gpiod-2.2.2.tar.gz
.
File metadata
- Download URL: gpiod-2.2.2.tar.gz
- Upload date:
- Size: 53.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa4571f64e1070d38e4c14c491f69637ee73e23c801d3a418dde4d5410e5d53f |
|
MD5 | 41770d72c0cad573e8da03d67fe695cf |
|
BLAKE2b-256 | 5abe9876843be7d8d3e05582de8919077b9084beac5d9791b139653e3048e4fd |
File details
Details for the file gpiod-2.2.2-cp312-cp312-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 97.9 kB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c069224bd529e7d2f23f3339a9aa2031f7eb2e53e06dbe32b088f15d66efd528 |
|
MD5 | 9c49e8986a662a7f69c42312e5b557bc |
|
BLAKE2b-256 | 4cedf92afab667070963d548beb6b3e57481633ccc4b80786ac5b3faa5e3e36e |
File details
Details for the file gpiod-2.2.2-cp312-cp312-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp312-cp312-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 98.3 kB
- Tags: CPython 3.12, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8318ee92b1f4828908850111dd2ea96cb76a565ad272388210d1c4041bf5060e |
|
MD5 | 74d7532af4b82b252959a70d43989b96 |
|
BLAKE2b-256 | 52a23adc36a6d19e8cf105e587f99304e48d6e818839026cff8ddf0470e22777 |
File details
Details for the file gpiod-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 99.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d717ff802015d35101a1c3eb0b0905967692999401e85a1f6672d1935a131899 |
|
MD5 | ae4d718c316f7b618c4c735e821f49d8 |
|
BLAKE2b-256 | ad36d3eae38cff0ccd9c2df272c6f7e3c4fea0dbbd86d94b9539a5a09b04b436 |
File details
Details for the file gpiod-2.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 100.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7961c1aa7f6a400bd01beb0f28c3525de6c2983a961d52426947b186e59dc29e |
|
MD5 | 52f2a5aa51680934f6e0482ac8fb8310 |
|
BLAKE2b-256 | 3c7a512b5d3b0f4ce444edfde8ac128a4de8fc2652f662ada762371abf777bab |
File details
Details for the file gpiod-2.2.2-cp311-cp311-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp311-cp311-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 98.0 kB
- Tags: CPython 3.11, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4eeda44ba7e7a20874e8ce0ac3be3921e0e31b70edd44a4b99cb12caf1a7ddde |
|
MD5 | 39156283ae84a726a0baa91b202da58d |
|
BLAKE2b-256 | ac3aaf227a1467e3903128437ace9360b51a3b3e2691fdf6b5467abc843aa3e9 |
File details
Details for the file gpiod-2.2.2-cp311-cp311-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp311-cp311-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 98.4 kB
- Tags: CPython 3.11, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4765c68f65db53cdfc8fd689b48a861e522a75d644d1557008dcf72e416258fc |
|
MD5 | 1ebf9d7a886d22d54b1c96d29e0a2515 |
|
BLAKE2b-256 | f0ababd021a5f509bdbf8bd70be3cc48368332febc4cb757c4a406db41009b6d |
File details
Details for the file gpiod-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 100.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97fdcb81676f94fe5afc65baf87c13f6c417afa05f826ee849eefe8deff9800d |
|
MD5 | 152451823572a3820fcc8ae4c7349449 |
|
BLAKE2b-256 | 139eff807f1052ee2a026a9d535a795d2f947555e1501a2277f49af7d21921fb |
File details
Details for the file gpiod-2.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 100.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90d92fc39ee5482694fce179adbc2718058a49958540327d2f735ffa5e2bd328 |
|
MD5 | 27ba1f9dbc86546d8d40bb0218c336c4 |
|
BLAKE2b-256 | 3c1e9eee450cd61f59c9c5e1d95e82b15f5faf45569b023ede0fe17c95465fef |
File details
Details for the file gpiod-2.2.2-cp310-cp310-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp310-cp310-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 96.3 kB
- Tags: CPython 3.10, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33e023d9e186b356aa9f3935eb3764ba78c95ff02216a973f5932daeac6b5ac1 |
|
MD5 | ffa925544daefe74480183b88ae76c30 |
|
BLAKE2b-256 | 96647a8a92da3fb9393d78414604c775b416c4ecb59ddad4c1a159f9d7ffcc34 |
File details
Details for the file gpiod-2.2.2-cp310-cp310-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp310-cp310-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 96.7 kB
- Tags: CPython 3.10, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14353ee82fd4ed69795ade31347bd1cfd84a79d79b526c66ee976c096583aa2b |
|
MD5 | 16f9b1c1e14d49fb33fdd0f19753aecb |
|
BLAKE2b-256 | d2052ffa4e9d26924cb1b9c5553f56c0baa4d770d987428798263c7c020be8a7 |
File details
Details for the file gpiod-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 98.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83b41485e74a7297d65a82add4c6e2302a94d0064413f75200062186984826f9 |
|
MD5 | 7cef40a085aaf98cef46874d2d2aacff |
|
BLAKE2b-256 | fd884ffc39e584b58201d752879624340aa67fa0cadbab257d07f30252c3fac6 |
File details
Details for the file gpiod-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 99.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca3ac692769e4c1fe79b43e973db8524b2f19df4778983cbf939534d84bf3448 |
|
MD5 | 33d094195c7b912120e2784dd9bfadb0 |
|
BLAKE2b-256 | 3abc0e38bafffcc4b36b9ccb657741fb320902ee24ec1acdfd6deb8ab779187c |
File details
Details for the file gpiod-2.2.2-cp39-cp39-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp39-cp39-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 95.6 kB
- Tags: CPython 3.9, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c7700eb543afb03d8015e38cadda06b0b5e2ccf8ac275d68bcf159dd95ec583 |
|
MD5 | cda34f57f2adecc9e26148fdc7cc3f61 |
|
BLAKE2b-256 | 0cb8ba37530eb1a3251270648db94c4fb2e085e06891ea91c301bbdcb5b6eaa3 |
File details
Details for the file gpiod-2.2.2-cp39-cp39-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp39-cp39-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 96.1 kB
- Tags: CPython 3.9, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11c9327312c0534a71e5b5b11ccea38d0609c41df22ee61b58f22e56525186a0 |
|
MD5 | 976601643bcb6cd824a730dd2833a68b |
|
BLAKE2b-256 | ec6be1fc797da3bc78688023a31f73a9f4df42b9cb98c318c9894b2cf05e4f15 |
File details
Details for the file gpiod-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 97.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31f7aece3252ec163abfcc4cded8b7348dbc8696ed81064ec8df623c163254dd |
|
MD5 | d2ebca7bc05e90a951cc1ac6718e61ad |
|
BLAKE2b-256 | f573816fb3ec7d0fae52ef956aff1b62eea6290cdefcb87fb3d8e7174bdf7589 |
File details
Details for the file gpiod-2.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: gpiod-2.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 98.3 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5a59ce4e57bca746ccc04b438535446c4b38ef637cf1b8fb9fe2e7380a0966a |
|
MD5 | df1130c76add78f3896f120de0ebe782 |
|
BLAKE2b-256 | 286e31536d6a2f32dc8070645c0088543b442f79467805c1a732f84de8ab4ac8 |