From: Phil Howard <phil@gadgetoid.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Kent Gibson <warthog618@gmail.com>,
Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-gpio@vger.kernel.org, Phil Howard <phil@gadgetoid.com>
Subject: [libgpiod][PATCH v2 0/1] bindings: python: standalone build tooling for tests
Date: Wed, 8 Nov 2023 15:51:59 +0000 [thread overview]
Message-ID: <20231108155200.3050417-1-phil@gadgetoid.com> (raw)
After much delibration about how in-place test builds should work, I have
pulled out all of the test extension code from setup.py into a new
build_tests.py and updated Makefile.am to invoke it.
This replaces the old `python3 setup.py build_ext --inplace` with enough
setuptools tooling to replicate that behaviour, while also putting it
in a better place to avoid problems arising from the deprecation of direct
setup.py invocation [1].
Since receipients of the gpiod Python bindings (in tar.gz source or .whl
binary format) won't need the test C extensions (and can't run them anyway
without the accompanying Python modules) the test extension code has been
removed from setup.py rather than duplicated into this new file.
The new build_tests.py creates a temporary directory and redirects all
build-time output into it. A final step - handled by build_ext and internal
to setuptools - then moves the built _ext.<python_version>-<arch>-<os>.so C
extensions into gpiod, tests/gpiosim and tests/procname where they can be
imported.
Since release packages and tests no longer share the build/ directory I
have removed the "rmtree" hack from the "build_ext" override in setup.py.
There should be no cases where test extensions can accidentally end up
being installed into the system/user Python environment.
To build and run tests:
- `make python-tests`
- `(sudo) make python-tests-run` (I need root for the gpiosim module)
Tested with setuptools==68.2.2 (Sep 2023), setuptools==59.8.0 (Dec 2021)
and setuptools==42.0.2 (Dec 2019).
Changes v1 -> v2:
- Add the gpiod ext module to build_tests.py (using glob for sources)
- Formalize the command for running tests by adding it to Makefile.am
- Add build_tests.py output artefacts to Makefile.am's clean-local target
- Sort distutils.log imports (DEBUG before set_verbosity)
Phil Howard (1):
bindings: python: standalone build tooling for tests
bindings/python/Makefile.am | 33 +++++++++---
bindings/python/build_tests.py | 95 ++++++++++++++++++++++++++++++++++
bindings/python/setup.py | 28 +---------
3 files changed, 121 insertions(+), 35 deletions(-)
create mode 100644 bindings/python/build_tests.py
--
2.34.1
next reply other threads:[~2023-11-08 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 15:51 Phil Howard [this message]
2023-11-08 15:52 ` [libgpiod][PATCH v2 1/1] bindings: python: standalone build tooling for tests Phil Howard
2023-11-09 10:37 ` Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231108155200.3050417-1-phil@gadgetoid.com \
--to=phil@gadgetoid.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).