diff mbox series

[libgpiod] bindings: python: relax the verbosity adjustment in build_tests.sh

Message ID 20241127133139.120107-1-brgl@bgdev.pl
State New
Headers show
Series [libgpiod] bindings: python: relax the verbosity adjustment in build_tests.sh | expand

Commit Message

Bartosz Golaszewski Nov. 27, 2024, 1:31 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

When building tests using the build_tests.py script, we try to increase
the verbosity using setuptools.logging.configure() preferably but
falling back to distutils.log.set_verbosity() if the former is missing.

This however creates a hard dependency on distutils on older environments
missing the recently added setuptools method. The build however, can work
fine even with default (low) verbosity so instead of bailing out if the
second import fails, just keep going.

Closes: https://github.com/brgl/libgpiod/issues/109
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/python/build_tests.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Bartosz Golaszewski Dec. 2, 2024, 8:30 a.m. UTC | #1
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Wed, 27 Nov 2024 14:31:39 +0100, Bartosz Golaszewski wrote:
> When building tests using the build_tests.py script, we try to increase
> the verbosity using setuptools.logging.configure() preferably but
> falling back to distutils.log.set_verbosity() if the former is missing.
> 
> This however creates a hard dependency on distutils on older environments
> missing the recently added setuptools method. The build however, can work
> fine even with default (low) verbosity so instead of bailing out if the
> second import fails, just keep going.
> 
> [...]

Applied, thanks!

[1/1] bindings: python: relax the verbosity adjustment in build_tests.sh
      commit: 27ec1af8b1836a1fcd6cbb8376324a21ee5b483e

Best regards,
diff mbox series

Patch

diff --git a/bindings/python/build_tests.py b/bindings/python/build_tests.py
index 84cedfc..ebe1727 100644
--- a/bindings/python/build_tests.py
+++ b/bindings/python/build_tests.py
@@ -82,9 +82,13 @@  try:
 
     configure()
 except ImportError:
-    from distutils.log import DEBUG, set_verbosity
+    try:
+        from distutils.log import DEBUG, set_verbosity
 
-    set_verbosity(DEBUG)
+        set_verbosity(DEBUG)
+    except ImportError:
+        # We can still build the tests, it will just be very quiet.
+        pass
 
 with tempfile.TemporaryDirectory(prefix="libgpiod-") as temp_dir:
     command = build_ext(dist)