summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2025-04-26 19:29:08 +0300
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2025-04-26 19:29:08 +0300
commit07d9958c9028062135bb0dd51ab76b3e15f40298 (patch)
tree0ddbeeeec075713b823e83775b08b584f9cab4c6
parentcd8bfcffced520e85e5340afa3a303d37ba708fb (diff)
py: Allow building pykms without libutils
-rw-r--r--py/pykms/__init__.py23
-rw-r--r--py/pykms/meson.build6
-rw-r--r--py/pykms/pykms.cpp3
3 files changed, 15 insertions, 17 deletions
diff --git a/py/pykms/__init__.py b/py/pykms/__init__.py
index 258b4e0..41447c1 100644
--- a/py/pykms/__init__.py
+++ b/py/pykms/__init__.py
@@ -3,17 +3,18 @@ from enum import Enum
import os
import struct
-#
-# Common RGB colours
-#
-
-red = RGB(255, 0, 0)
-green = RGB(0, 255, 0)
-blue = RGB(0, 0, 255)
-yellow = RGB(255, 255, 0)
-purple = RGB(255, 0, 255)
-white = RGB(255, 255, 255)
-cyan = RGB(0, 255, 255)
+if has_pykmsutils():
+ #
+ # Common RGB colours
+ #
+
+ red = RGB(255, 0, 0)
+ green = RGB(0, 255, 0)
+ blue = RGB(0, 0, 255)
+ yellow = RGB(255, 255, 0)
+ purple = RGB(255, 0, 255)
+ white = RGB(255, 255, 255)
+ cyan = RGB(0, 255, 255)
#
# Rotation enum
diff --git a/py/pykms/meson.build b/py/pykms/meson.build
index de05d12..ed8ab46 100644
--- a/py/pykms/meson.build
+++ b/py/pykms/meson.build
@@ -1,10 +1,4 @@
-# Python bindings require libutils for now.
-if not get_option('libutils')
- pybindings_enabled = false
- subdir_done()
-endif
-
py3_dep = dependency('python3', required : get_option('pykms'))
if py3_dep.found() == false
diff --git a/py/pykms/pykms.cpp b/py/pykms/pykms.cpp
index 0c17c4c..ccc597b 100644
--- a/py/pykms/pykms.cpp
+++ b/py/pykms/pykms.cpp
@@ -23,6 +23,9 @@ PYBIND11_MODULE(pykms, m)
#if HAS_KMSXXUTIL
init_pykmsutils(m);
+ m.def("has_pykmsutils", []() { return true; });
+#else
+ m.def("has_pykmsutils", []() { return false; });
#endif
#if HAS_LIBDRM_OMAP