commit:     3a7fbdfb074e7482ca1ded2e5eafbb915f20fd99
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  4 11:27:20 2022 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Tue Oct  4 12:50:20 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3a7fbdfb

app-misc/ola: support installing Python bindings

Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>

 .../files/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(-)

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 000000000000..a4a82f916fa0
--- /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 fe23c959e3e0..90cb6324410e 100644
--- a/app-misc/ola/metadata.xml
+++ b/app-misc/ola/metadata.xml
@@ -19,5 +19,6 @@
        <use>
                <flag name="ftdi">Support FTDI devices</flag>
                <flag name="http">Enable built-in Web UI</flag>
+               <flag name="rdm-tests">Install RDM responder tests</flag>
        </use>
 </pkgmetadata>

diff --git a/app-misc/ola/ola-0.10.8.ebuild b/app-misc/ola/ola-0.10.8.ebuild
index e9fa6752713f..bcb9094e62e1 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
 }

Reply via email to