From 3a7fbdfb074e7482ca1ded2e5eafbb915f20fd99 Mon Sep 17 00:00:00 2001 From: Marek Szuba Date: Tue, 4 Oct 2022 12:27:20 +0100 Subject: [PATCH] app-misc/ola: support installing Python bindings Signed-off-by: Marek Szuba --- .../ola-0.10.8-python_version_check.patch | 31 ++++++++++++++ app-misc/ola/metadata.xml | 1 + app-misc/ola/ola-0.10.8.ebuild | 41 ++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 app-misc/ola/files/ola-0.10.8-python_version_check.patch diff --git a/app-misc/ola/files/ola-0.10.8-python_version_check.patch b/app-misc/ola/files/ola-0.10.8-python_version_check.patch new file mode 100644 index 0000000000000..a4a82f916fa06 --- /dev/null +++ b/app-misc/ola/files/ola-0.10.8-python_version_check.patch @@ -0,0 +1,31 @@ +--- a/python/ola/OlaClient.py ++++ b/python/ola/OlaClient.py +@@ -952,7 +952,7 @@ + controller = SimpleRpcController() + request = Ola_pb2.DmxData() + request.universe = universe +- if sys.version >= '3.2': ++ if sys.version_info[:3] >= (3,2): + request.data = data.tobytes() + else: + request.data = data.tostring() +--- a/python/ola/PidStore.py ++++ b/python/ola/PidStore.py +@@ -645,7 +645,7 @@ + (self.name, self.min)) + + try: +- if sys.version >= '3.2': ++ if sys.version_info[:3] >= (3,2): + data = struct.unpack('%ds' % arg_size, bytes(arg, 'utf8')) + else: + data = struct.unpack('%ds' % arg_size, arg) +@@ -668,7 +668,7 @@ + except struct.error as e: + raise UnpackException(e) + +- if sys.version >= '3.2': ++ if sys.version_info[:3] >= (3,2): + return value[0].rstrip(b'\x00').decode('utf-8') + else: + return value[0].rstrip(b'\x00') diff --git a/app-misc/ola/metadata.xml b/app-misc/ola/metadata.xml index fe23c959e3e09..90cb6324410ef 100644 --- a/app-misc/ola/metadata.xml +++ b/app-misc/ola/metadata.xml @@ -19,5 +19,6 @@ Support FTDI devices Enable built-in Web UI + Install RDM responder tests diff --git a/app-misc/ola/ola-0.10.8.ebuild b/app-misc/ola/ola-0.10.8.ebuild index e9fa6752713f2..bcb9094e62e12 100644 --- a/app-misc/ola/ola-0.10.8.ebuild +++ b/app-misc/ola/ola-0.10.8.ebuild @@ -3,7 +3,9 @@ EAPI=8 -inherit autotools +PYTHON_COMPAT=( python3_{8..10} ) + +inherit autotools python-single-r1 DESCRIPTION="Open Lighting Architecture, a framework for lighting control information" HOMEPAGE="https://www.openlighting.org/ola/" @@ -12,7 +14,10 @@ SRC_URI="https://github.com/OpenLightingProject/${PN}/releases/download/${PV}/${ LICENSE="GPL-2+ LGPL-2.1+" SLOT="0" KEYWORDS="~amd64" -IUSE="examples ftdi http osc tcmalloc test usb zeroconf" +IUSE="examples ftdi http osc python rdm-tests tcmalloc test usb zeroconf" + +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} ) + rdm-tests? ( python )" RESTRICT="!test? ( test )" @@ -22,6 +27,17 @@ RDEPEND="dev-libs/protobuf:= ftdi? ( dev-embedded/libftdi:1 ) http? ( net-libs/libmicrohttpd:= ) osc? ( media-libs/liblo ) + python? ( + ${PYTHON_DEPS} + $(python_gen_cond_dep ' + dev-python/protobuf-python[${PYTHON_USEDEP}] + ') + ) + rdm-tests? ( + $(python_gen_cond_dep ' + dev-python/numpy[${PYTHON_USEDEP}] + ') + ) tcmalloc? ( dev-util/google-perftools:= ) usb? ( virtual/libusb:1 ) zeroconf? ( net-dns/avahi )" @@ -32,8 +48,19 @@ BDEPEND="sys-devel/bison virtual/pkgconfig test? ( dev-util/cppunit + python? ( + ${PYTHON_DEPS} + $(python_gen_cond_dep ' + dev-python/numpy[${PYTHON_USEDEP}] + dev-python/protobuf-python[${PYTHON_USEDEP}] + ') + ) )" +PATCHES=( + "${FILESDIR}"/${PN}-0.10.8-python_version_check.patch +) + src_prepare() { default # Upstream recommends doing this even for tarball builds @@ -48,6 +75,8 @@ src_configure() { $(use_enable ftdi libftdi) $(use_enable http) $(use_enable osc) + $(use_enable python python-libs) + $(use_enable rdm-tests) $(use_enable tcmalloc) $(use_enable test unittests) $(use_enable usb libusb) @@ -57,5 +86,13 @@ src_configure() { src_install() { default + find "${ED}" -name '*.la' -delete || die + + if use examples && use python; then + docinto examples + python_fix_shebang python/examples/*.py + dodoc python/examples/*.py + docompress -x /usr/share/doc/${PF}/examples + fi }