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>
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>
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>
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>
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 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>
Makefile.am delegates the build of the python extension to its
setup.py file, which references the extension .c files relative to the
source dir. This makes it impossible to build in a directory that is
different from the source directory (for example, for PC and ARM but
from the same source).
* Invoke setup.py from $(srcdir)
* Modify setup.py to pick up .c files relative from setup.py's own
directory.
Signed-off-by: Joerg Faschingbauer <jf@faschingbauer.co.at>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
When we run the test suite by calling the __main__ function of the module,
the name of the process as visible in the system becomes "python". Let's
set it to "python-gpiod" before running the tests. This way gpiosim will
name its configfs attributes appropriately.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Currently in order to disable test the variable needs to be explicitly
set to GPIOD_WITH_TESTS= in the environment or setup.py will crash.
Assume tests should not be built if the variable is not set at all.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Python bindings now have their own setup.py script and can be built
separately from the rest of the code-base. Let's decouple the python
package version from libgpiod API (but let's keep a module attribute
containing the API version) by introducing a version.py submodule that
can be executed by the setup.py script. This way we have a single
canonical place defining the version number.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is the result of a squash of all the commits created during
the development of libgpiod v2. This is done to preserve bisectability
of the git tree. It contains significant re-writes of the core C library
as well as C++ and python bindings. The tools have been adjusted to work
with the new API but have not undergone significant changes yet.
This commit contains the bulk of the work on libgpiod v2 but the
development continues with more changes planned.
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
[Ben: fix format specifier for uint64_t]
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
[Viresh: Fix ioctl number for gpiod_line_request_reconfigure_lines()]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
[Kent: bug fixes, improvements, better pointer contracts, type strictness]
Signed-off-by: Kent Gibson <warthog618@gmail.com>