build_tests.py is not part of the sdist so tests cannot be built from
pypi releases. Add it to MANIFEST.in.
Fixes: d588a6a592 ("bindings: python: standalone build tooling for tests")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This is a small bugfix release improving how the C extensions for python
bindings tests are built.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Move extension definitions and tooling for building tests into
`build_tests.py` and update Makefile.am to call it with appropriate path
prefixes.
`build_tests.py` will perform a standalone build of the text extensions,
keeping any build noise in a temporary directory and copying the final
built modules automatically out to `tests/gpiosim` and `tests/procname`.
Add "python-tests-run" to Makefile.am so it's clear how to run the tests.
Add .so object files generated by build_test.py to Makefile.am's
clean-local.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This is a small bugfix release of the python bindings fixing how the
homepage on pypi is displayed.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Replace the # (which is a markdown heading) with HTML tags to hide SPDX
identifier tags within the project description on pypi.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
One of the example scripts is named differently than what the Makefile
lists it as. Change the EXTRA_DIST variable to fix it.
Fixes: 96c52d3e59 ("bindings: python: examples: replace tools examples with use case examples")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
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>
Move the long_description into README.md and include some basic
information about libgpiod, and some simple Python example code.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We now control the name 'gpiod' on pypi. Let's change the project name
as the package we import in python code is named 'gpiod' and not
'libgpiod'
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The presence of _distutils in setuptools is an implementation detail. If
we want anything from the distutils package, we should import it directly.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Use environ.get() in lieu of an explicit check for GPIOD_WITH_TESTS in
os.environ.
Returns None and evaluates as False if GPIOD_WITH_TESTS == "1" is
not specified.
Signed-off-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
PyModule_AddObjectRef() was added in cpython v3.10 while libgpiod claims
to depend on python v3.9. Replace it with an older variant that steals the
reference to the added object on success.
Reported-by: Phil Howard <phil@gadgetoid.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
There are no thread-safety guarantees in libgpiod. Let's not reuse the
chip object created in one thread to generate info events in another but
use a global request function instead.
Reported-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
Provide a wrapper around gpiod_line_request_get_chip_name() for Python
bindings and update the tests.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
A collection of minor changes to be more consistent with other examples:
- capitalize comments
- add line offset to value outputs
- drop comma from edge event outputs
- improve behaviour if run on a platform that does not match the
example configuration
- use with to cleanup request in toggle_line_value.py
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add new example scripts to EXTRA_DIST in the Makefile so that they end up
being shipped with the rest of the code.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpioset.py requests lines without setting their output value, and so
sets them all inactive, and subsequently sets them to their requested
value. This can result in glitches on lines which were active and
are set active.
As this is example code, it is also important to demonstrate that the
output value can be set by the request itself.
Request the lines with the correct output values set in the request
itself.
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We're currently unintentionally exporting a bunch of symbols that should
remain local to sub-modules. Use __all__ where appropriate so that we
don't re-export standard library functions such as select() etc. in the
gpiod module.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The docs don't mention it but currently passing None as the timeout to
one of the event wait methods works like passing 0 to select() - the wait
method returns immediately. Change it to a more standard behavior - None
makes the method block indefinitely until an event becomes available for
reading.
This is a slight change in the behavior but let's hope nobody complains
as libgpiod v2 is still pretty recent and its adoption is (hopegully)
not wide-spread yet.
Reported-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Suggested-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
The manifest is not being bundled with the distribution tarball. Add it
to EXTRA_DIST.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We want to ship the source code for C extensions used by the test suite
but not install the built shared objects or put them into the bdist.
Extend the build_ext command to delete the tests from the build directory
right after the extensions have been built and - possibly - installed
into the source tree (if --inplace is set).
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This reverts commit addf968c73.
We're moving towards being compatible with PEP 517 for building and
currently the following error happens when running setup.py build_py:
running build_py
error: Error: setup script specifies an absolute path:
<snip>/libgpiod/bindings/python/./gpiod/ext/chip.c
setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.
As the Makefile build should only be used for development purposes, I
think we can safely drop support for out-of-tree build. Python bindings
have now been spun out into their own tarball and are available to
install from pip.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We already exclude 'tests' but 'tests.*' must be excluded as well if we
don't want to install the gpiosim and procname submodules.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The name of the project has changed so the egg-info directory is no
longer ignored. Update .gitignore but make the entry more general.
Fixes: d5a454cda5 ("bindings: python: change the project name to libgpiod")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Update the version of python bindings to v2.0.1. I treat it as a bug-fix
release as the changes only apply to packaging and building (in
preparation for making the package available on pypi) and there are no
functional changes in the bindings.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
__main__.py and __init__.py are omitted with the default source discovery
so add an explicit recursive include for tests in order to package them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add a long description that will be displayed on the main page once we
make the project available on pypi.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We want to package the .c sources for test-specific extensions so add
them to the manifest.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We currently "include" the gpiod package in find_packages() which does
nothing as it would be discovered anyway. We want to package the test
sources but exclude it from the binary wheel so use the "exclude"
argument.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The name 'gpiod' is already taken on pypi. Switch to using 'libgpiod'
as the name of the project. Keep 'gpiod' as the package name which
maintains code compatibility.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
In order to allow building sdist and wheel packages for python bindings
with python3-build, add a proper MANIFEST.in file.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
It seems like every release there's some new problem with parsing the
version strings in tests. Let's reduce the strictness of the patterns
to avoid future test failures and accept the following version schemes:
X.Y
X.Y.Z
X.Y-devel
X.Y-rcZ
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The square bracket is in the wrong place which makes the regex not match
version strings of the form: x.y.z. Fix the pattern in core and bindings
tests.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add a new Python code examples - gpionotify.py - which is a simplified
reimplementation of the gpionotify tool.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Two-digit versions are not correctly parsed as the last "segment" is not
optional as it should.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
GPIOD_VERSION_STRING environment variable is no longer used by setup.py.
It's been replaced by reading the version from the variable defined in
version.py.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
One of the test cases doesn't release the request object leading to the
following warning in the kernel log:
REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED
Fix it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The GPIOD_WITH_TESTS environment variable is not used by setup.py install
command. Drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
As per automake docs:
The DESTDIR variable can be used to perform a staged installation. The
package should be configured as if it was going to be installed in its
final location (e.g., --prefix /usr), but when running make install, the
DESTDIR should be set to the absolute name of a directory into which the
installation will be diverted. From this directory it is easy to review
which files are being installed where, and finally copy them to their
final location by some means.
Prefix $(prefix) with $(DESTDIR) when calling setup.py.
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Using the __FILE__ macro contaminates the build artifacts with global
build host file system paths. Don't use it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add a new optional argument to Chip.request_lines() called output_values.
It accepts a dictionary of mappings between line names or offsets to the
output values the requested lines should be set to at request-time.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>