Vincent Fazio
c0650edd44
bindings: python: add a changelog
...
Add a changelog to summarize changes to the bindings between releases.
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://patch.msgid.link/20260527215922.18678-4-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com >
2026-05-28 11:01:02 +02:00
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
Vincent Fazio
530fa7823b
bindings: python: update linter configuration
...
Simplify linter configuration to check all files in the bindings
directory while excluding files in .gitignore.
With a minimum mypy version of 1.18.1, the `strict_equality` knob can
be removed as it was a work around a known issue [0] that is now fixed.
With a minimum ruff version of 15.x, rename the TCH check to TC since
it was renamed in v0.8.0 [1].
[0]: https://github.com/python/mypy/issues/10910
[1]: https://github.com/astral-sh/ruff/releases/tag/0.8.0
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://patch.msgid.link/20260401001459.19159-9-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com >
2026-04-03 11:00:36 +02:00
Vincent Fazio
5efa9e8144
bindings: python: add a lint dependency group
...
Specify useful dependencies for linting the bindings and related code.
The group can be installed with `pip install --group lint`.
As part of this group, specify version ranges for mypy and ruff to keep
linting consistent until new minimal versions of Python are targeted or
until the new annual style introduced by ruff is chosen.
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://patch.msgid.link/20260401001459.19159-8-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com >
2026-04-03 11:00:36 +02:00
Vincent Fazio
950ff3d1b3
bindings: python: drop python 3.9 support
...
* Update pyproject.toml to require Python 3.10+ for runtime
* Update mypy's target version to 3.10 syntax
* Drop ruff's target version as it's inferred by the project's
requires-python value
* Remove the linter settings that ignored UP007 & UP0045
* Update type annotations to conform to active linter rules
Closes: https://github.com/brgl/libgpiod/issues/151
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://patch.msgid.link/20260329182832.39824-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com >
2026-03-30 10:57:47 +02:00
Vincent Fazio
42fcd4c084
bindings: python: remove wheel from build dependencies
...
The `wheel` package is not actually a build dependency for the project
since it is not imported during setup.
The `setuptools` documentation [0] says it was documented as required at
one point and that most packages have cargo culted the inclusion.
[0]: https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://patch.msgid.link/20260328153830.57177-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com >
2026-03-30 10:32:08 +02:00
Vincent Fazio
ff267fb439
bindings: python: require newer setuptools
...
When commit d9b156ecc2 updated pyproject.toml to conform to PEP 639
we failed to make sure the build dependencies were updated to support
the new structure.
Support for PEP 639 was added to setuptools in v77.0.0 [0] so minimally
require that version in `build-system.requires` to avoid failures.
Link: https://setuptools.pypa.io/en/latest/history.html#v77-0-0 # [0]
Fixes: d9b156ecc2 ("bindings: python: make licensing information conform with PEP 639")
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://patch.msgid.link/20260217005314.31016-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com >
2026-02-18 09:25:30 +01:00
Vincent Fazio
97ee308728
bindings: python: generate wheels for CPython 3.14
...
Update cibuildwheel to add support for generating 3.14 wheels.
Configuration options for cibuildwheel have been moved to pyproject.toml
to keep it in line with other tools used by the bindings.
The configuration has been updated to skip generating free-threaded
wheels since the bindings do not support free-threaded builds [0] and
cibuildwheel generates them by default starting with CPython3.14 [1].
[0]: https://github.com/brgl/libgpiod/issues/117
[1]: https://github.com/pypa/cibuildwheel/pull/2503
Closes: https://github.com/brgl/libgpiod/issues/138
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://lore.kernel.org/r/20250923200737.3177136-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2025-09-26 11:54:44 +02:00
Vincent Fazio
4db8707554
bindings: python: disable UP045 linter check
...
Linter check UP045 [0] was recently stabilized in ruff 0.12 [1].
UP045 suggests using the `X | Y` syntax for files that perform:
from __future__ import annotations
This import drives the Python interpreter to store type annotations as
strings and defers their evaluation [2] making the new syntax "safe".
See also [3] for a brief history.
For now, disable the UP045 linter warnings like we do UP007 [4] for the
sake of consistency within the bindings so there is no mixed usage of
`Union[X, Y]` and `Optional[X]` vs `X | Y` until the bindings minimally
target Python 3.10 and can move to the latter syntax.
[0]: https://docs.astral.sh/ruff/rules/non-pep604-annotation-optional/
[1]: de4fc5b171
[2]: https://peps.python.org/pep-0563/#implementation
[3]: https://peps.python.org/pep-0649/#a-history-of-annotations
[4]: https://docs.astral.sh/ruff/rules/non-pep604-annotation-union/
Signed-off-by: Vincent Fazio <vfazio@gmail.com >
Link: https://lore.kernel.org/r/20250907142919.1382670-1-vfazio@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2025-09-09 11:24:36 +02:00
Bartosz Golaszewski
d9b156ecc2
bindings: python: make licensing information conform with PEP 639
...
Follow the PEP 639 specification and remove the deprecated license
classifier as well as make the license key in the [project] table a
top-level string containing the SPDX license identifier.
Reviewed-by: Vincent Fazio <vfazio@xes-inc.com >
Link: https://lore.kernel.org/r/20250424-pyproject-toml-pep-639-v1-2-8150d3d807b1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2025-04-30 10:34:58 +02:00
Bartosz Golaszewski
d0c8c18ae8
bindings: python: add missing newline to pyproject.toml
...
There's a newline missing at the end of pyproject.toml. Add it.
Reviewed-by: Vincent Fazio <vfazio@xes-inc.com >
Link: https://lore.kernel.org/r/20250424-pyproject-toml-pep-639-v1-1-8150d3d807b1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2025-04-30 10:34:40 +02:00
Vincent Fazio
1ee51f95c5
bindings: python: migrate metadata to pyproject.toml
...
PEP 621 [0] designated pyproject.toml as the standard place to store
project metadata.
Setuptools, the build system used by this project, has support for
reading metadata from this location. As such, migrate the majority of
the metadata out of `setup.py`.
For now, the external modules are left declared in `setup.py` because
support within pyproject.toml is still experimental [1].
New metadata has been added/updated, namely:
* Add Trove classifiers
* Add a link to the issues page
* Update license from LGPL-2.1 to LGPL-2.1+ to match SPDX identifier
[0]: https://peps.python.org/pep-0621/
[1]: https://setuptools.pypa.io/en/stable/userguide/ext_modules.html#pyproject-toml
Closes: https://github.com/brgl/libgpiod/issues/107
Signed-off-by: Vincent Fazio <vfazio@xes-inc.com >
Link: https://lore.kernel.org/r/20241122171027.762311-1-vfazio@xes-inc.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2024-11-27 11:33:57 +01:00
Vincent Fazio
0505dc3643
bindings: python: configure and document dev dependencies
...
Mypy [0] is a popular static type checker that validates attribute and
variable use and ensures function arguments adhere to type annotations.
Ruff [1] is a popular Rust-based Python linter and code formatter. It
has support for a large set of linting rules [2] and largely complies
with the Black format [3].
Add documentation to README.md for how to run the tools.
[0]: https://mypy.readthedocs.io/en/stable/
[1]: https://docs.astral.sh/ruff/
[2]: https://docs.astral.sh/ruff/rules/
[3]: https://docs.astral.sh/ruff/formatter/#black-compatibility
Signed-off-by: Vincent Fazio <vfazio@xes-inc.com >
Link: https://lore.kernel.org/r/20241114145116.2123714-24-vfazio@xes-inc.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2024-11-19 15:23:58 +01:00
Phil Howard
0e81b62c01
bindings: python: optionally include module in sdist
...
Optionally vendor libgpiod source into sdist so that the Python module can
be built from source, even with a missing or mismatched system libgpiod.
Add two new environment variables "LINK_SYSTEM_LIBGPIOD" and
"LIBGPIOD_VERSION" to control what kind of package setup.py will build.
In order to build an sdist or wheel package with a vendored libgpiod a
version must be specified via the "LIBGPIOD_VERSION" environment variable.
This will instruct setup.py to verify the given version against the list
in sha256sums.asc and ensure it meets or exceeds a LIBGPIOD_MINIMUM_VERSION
required for compatibility with the bindings.
It will then fetch the tarball matching the requested version from
mirrors.edge.kernel.org, verify the sha256 signature, unpack it, and copy
the lib and include directories into the package root so they can be
included in sdist or used to build a binary wheel.
eg: LIBGPIOD_VERSION=2.1.0 python3 setup.py sdist
Will build a source distribution with gpiod version 2.1.0 source included.
It will also save the gpiod version into "libgpiod-version.txt" so that it
can be passed to the build when the sdist is built by pip.
Requiring an explicit version ensures that the Python bindings - which
can be changed and versions independent of libgpiod - are built against a
stable libgpiod release.
In order to force a package with vendored gpiod source to link the system
libgpiod, the "LINK_SYSTEM_LIBGPIOD" environment variable can be used:
eg: LINK_SYSTEM_LIBGPIOD=1 pip install libgpiod
Signed-off-by: Phil Howard <phil@gadgetoid.com >
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2023-11-03 11:36:28 +01:00
Phil Howard
85089d0e40
bindings: python: add pyproject.toml, pep 518
...
Add pyproject.toml to prevent spurious deprecation warnings from pip.
Signed-off-by: Phil Howard <phil@gadgetoid.com >
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
2023-10-13 10:35:01 +02:00