1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-25 12:39:18 +03:00
Commit Graph

18 Commits

Author SHA1 Message Date
Kent Gibson
dee10f0807 bindings: python: fix python-tests-run make target
The python-tests-run target is broken as it does not correctly split
lines.  It also calls Python directly rather then through the $PYTHON
variable.

Fix the line splitting and call Python using the $PYTHON variable.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20240526113234.253859-3-warthog618@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-05-28 11:13:15 +02:00
Bartosz Golaszewski
40adfc1eb6 bindings: python: fix package installation with Makefile build
The modules are installed in the .egg directory, and therefore cannot be
imported after that. Additionally PIP tries to remove the global gpiod
module if it's not invoked with the --ignore-installed option.

Specify correct --root and fix the --prefix switch.

Link: https://github.com/pypa/pip/issues/3063
Suggested-by: Maxim Devaev <mdevaev@gmail.com>
Reported-by: Maxim Devaev <mdevaev@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-01-09 20:09:37 +01:00
Phil Howard
d588a6a592 bindings: python: standalone build tooling for tests
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>
2023-11-08 20:50:02 +01:00
Bartosz Golaszewski
e35621c447 bindings: python: add MANIFEST.in to EXTRA_DIST
The manifest is not being bundled with the distribution tarball. Add it
to EXTRA_DIST.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-25 18:02:46 +02:00
Bartosz Golaszewski
4e75476ccb Revert "bindings: python: fix out-of-tree build"
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>
2023-04-18 14:50:33 +02:00
Bartosz Golaszewski
7da48116d0 bindings: python: remove unneeded setup.py argument
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>
2023-03-02 15:37:46 +01:00
Bartosz Golaszewski
8b99eb43f2 bindings: python: don't pass GPIOD_WITH_TESTS to 'setup.py install'
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>
2023-02-13 20:58:18 +01:00
Bartosz Golaszewski
ddc3f7b62a bindings: python: pass DESTDIR to setup.py
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>
2023-02-13 18:21:08 +01:00
Joerg Faschingbauer
addf968c73 bindings: python: fix out-of-tree build
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>
2023-01-18 10:21:18 +01:00
Bartosz Golaszewski
b7ba732e6a treewide: libgpiod v2 implementation
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>
2022-10-31 11:15:14 +01:00
Bartosz Golaszewski
154e7c5a82 licensing: relicense non-library code under GPL-2.0-or-later
LGPL-2.1 is a license meant for shared libraries. Because I didn't know
any better I used it for all files in the repository, including programs
linking against libgpiod. The standard approach for many similar projects
is to use LGPL for library code and GPL for programs (and also Makefiles
and other files containing code or configuration).

Relicense all programs, tests, makefiles and autotools files under
GPL-2.0 or later.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Kent Gibson <warthog618@gmail.com>
2021-02-18 17:42:12 +01:00
Bartosz Golaszewski
dfb707c255 licensing: make the project REUSE-compliant
In order to make the licensing situation of libgpiod clear and enable
easy reusing of the code, let's make all the files in the repository
compliant with the REUSE v3.0 specification.

In order to achieve that:
  - put all used licenses into a separate LICENSES/ directory
  - add SPDX license identifiers to all files that were missing them with
    regular text files being licensed under CC-BY-SA-4.0, while files
    containing code and configuration are licensed under GPL-2.0-or-later
  - replace custom copyright texts with SPDX-FileCopyrightText
  - update the gpio.h kernel uAPI header with the upstream version where
    the SDPX license identifier was fixed to use 'GPL-2.0-only' variant
    instead of the deprecated 'GPL-2.0'

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Kent Gibson <warthog618@gmail.com>
2021-02-18 17:42:08 +01:00
Bartosz Golaszewski
5e9e7223a3 build: add a configure switch for building examples
Example code for bindings is currently always built if bindings are
enabled. Make it conditional with a new configure switch.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2020-12-14 15:57:12 +01:00
Bartosz Golaszewski
c89e9565cf build: use the gnu89 C standard explicitly
We're already using it implicitly but GCC may change the default
standard to gnu99 at some point, so use gnu89 explicitly whenever
building C files.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-03-17 18:08:36 +01:00
Bartosz Golaszewski
452696601a bindings: python: use unittest to implement a proper test-suite
Currently the only tests we have for python bindings are in a simple
script that makes a lot of assumptions about the environment and
doesn't even work anymore with recent kernels.

Remove it and replace it with a proper test-suite implemented using
libgpiod and the standard python unittest package.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-08-09 14:52:01 +02:00
Bartosz Golaszewski
8159d9b540 treewide: rearrange source directories
The src directory containing lib and tools is not necessary and will
actually cause problems if we tried to add a new component to src/
which would depend on libraries from the bindings directory because it
(bindings) already depends on src/lib.

Simplify the directory structure. Move lib and tools to the root source
directory and update all relevant files. That way we can specify the
exact build order of components from the top source Makefile.am.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-03-07 13:49:00 +01:00
Bartosz Golaszewski
696de1b973 build: fix cross-compilation of python bindings
AX_PYTHON_DEVEL macro from the autoconf-archive collection doesn't work
when we're trying to cross-compile python bindings in environments such
as buildroot or yocto. It can't properly detect the location of python
headers.

Let's use AM_PATH_PYTHON to detect the python3 interpreter and then
either take the PYTHON_CPPFLAGS and PYTHON_LIBS variables from the
environment (so that cross-compiling build systems can pass their
custom locations to autotools) or try to detect them ourselves using
the python3-config tool.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-04-20 14:10:09 +02:00
Bartosz Golaszewski
96c524c495 bindings: implement python bindings
Create a C extension module wrapping the functionality of libgpiod
in a set of Python classes.

Add code examples including simplified reimplementations of gpio-tools
in Python.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-04-17 10:19:34 +02:00