[bug#77927,1/4] gnu: Add libiio

Message ID b0454c424a44f4d9439caa00f08aec66815b49bf.1744739324.git.rutherther@ditigal.xyz
State New
Headers
Series Support for PlutoSDR in SDR++ and SDRangel |

Commit Message

Rutherther April 19, 2025, 6:53 p.m. UTC
  This is a dependency used for communicating with PlutoSDR.

* gnu/packages/radio.scm (libiio): New variable.

Change-Id: Ic34895af35fa008923fed0de74ad12ffc75f2021
---
 gnu/packages/radio.scm | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)


base-commit: 12a6dd40a7b88454cc8a8c930c22681fcee5b1ea
  

Comments

Guillaume Le Vaillant April 20, 2025, 12:57 p.m. UTC | #1
Rutherther via Guix-patches via <guix-patches@gnu.org> skribis:

> +(define-public libiio
> +  (package
> +    (name "libiio")
> +    (version "0.24")
> [...]
> +    (arguments
> +     (list
> +      #:tests? #f
> +      #:configure-flags
> +      #~(list
> +         (string-append "-DUDEV_RULES_INSTALL_DIR=" #$output "/lib/udev/rules.d")
> +         "-DOSX_PACKAGE=off"
> +         "-DOSX_FRAMEWORK=off"
> +         (string-append "-DPython_EXECUTABLE=" (search-input-file %build-inputs "/bin/python3"))
> +         "-DPYTHON_BINDINGS=on")))
> [...]

Hi.
It looks like the installation of the Python bindings does not work;
they are not in the built package.
The build log indicates:

--8<---------------cut here---------------start------------->8---
running install
/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
Traceback (most recent call last):
  File "/tmp/guix-build-libiio-0.24.drv-0/build/bindings/python/setup.py", line 75, in _check_libiio_installed
    raise OSError
OSError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/guix-build-libiio-0.24.drv-0/build/bindings/python/setup.py", line 104, in <module>
    setup(**config)
  File "/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
    self.run_command(cmd)
  File "/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/gnu/store/mzhsp3vxj58hhbkrjdrvk9l47pk07kax-python-minimal-3.11.11/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.run()
  File "/tmp/guix-build-libiio-0.24.drv-0/build/bindings/python/setup.py", line 43, in run
    self._check_libiio_installed()
  File "/tmp/guix-build-libiio-0.24.drv-0/build/bindings/python/setup.py", line 81, in _check_libiio_installed
    raise Exception(msg)
Exception: The libiio library could not be found.
            libiio needs to be installed first before the python bindings.
            The latest release can be found on GitHub:
            https://github.com/analogdevicesinc/libiio/releases
--8<---------------cut here---------------end--------------->8---

Could you take a look at it?
  
Rutherther April 20, 2025, 4:23 p.m. UTC | #2
Guillaume Le Vaillant <glv@posteo.net> writes:

> Hi.
> It looks like the installation of the Python bindings does not work;
> they are not in the built package.
> The build log indicates:

Hi,
right, thanks. I didn't actually use them, so I didn't care to check,
sorry for that. I actually didn't think much and copied most of this
from nixpkgs, except for the patches! Seems that the package actually
doesn't like our approach of first building and then installing and
would like to be first installed, and later on built and installed
again, with the bindings on.
I've added patch to not check this, and to hardcode path to the library
so that it doesn't have to be in ld library path...

It's a question which bindings should we enable anyway... I don't
know... For the sdrangel and sdr++ no bindings are necessary, just the
library. Apart from Python ones there is CPP and C#.

Anyway, for now I submitted version with Python bindings only, compiling
and working fine - I can import the iio library without failing to find
any symbols.

I can't check with hardware anymore, I've had PlutoSDR just borrowed for
a few days.
  

Patch

diff --git a/gnu/packages/radio.scm b/gnu/packages/radio.scm
index 3724988ce4..df3574b5e3 100644
--- a/gnu/packages/radio.scm
+++ b/gnu/packages/radio.scm
@@ -49,6 +49,7 @@  (define-module (gnu packages radio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
@@ -56,6 +57,7 @@  (define-module (gnu packages radio)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages engineering)
+  #:use-module (gnu packages flex)
   #:use-module (gnu packages fltk)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gd)
@@ -190,6 +192,59 @@  (define-public libcorrect
 used as a drop-in substitute for @code{libfec}.")
       (license license:bsd-3))))
 
+(define-public libiio
+  (package
+    (name "libiio")
+    (version "0.24")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/analogdevicesinc/libiio")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "136n22macjz70bgxd7ix77gkv7zhbk3zzl340kwwpmb94z2fr4bk"))))
+    (arguments
+     (list
+      #:tests? #f
+      #:configure-flags
+      #~(list
+         (string-append "-DUDEV_RULES_INSTALL_DIR=" #$output "/lib/udev/rules.d")
+         "-DOSX_PACKAGE=off"
+         "-DOSX_FRAMEWORK=off"
+         (string-append "-DPython_EXECUTABLE=" (search-input-file %build-inputs "/bin/python3"))
+         "-DPYTHON_BINDINGS=on")))
+    (native-inputs
+     (list
+      pkg-config
+      flex
+      bison
+      python
+      avahi
+      libaio))
+    (inputs
+     (list
+      libxml2
+      libusb))
+    (build-system cmake-build-system)
+    (license (list
+              license:lgpl2.1
+              license:gpl2))
+    (home-page "https://github.com/analogdevicesinc/libiio")
+    (synopsis "A cross platform library for interfacing with local and remote Linux IIO devices ")
+    (description
+     "Library for interfacing with Linux IIO devices
+libiio is used to interface to the Linux Industrial Input/Output (IIO) Subsystem.
+The Linux IIO subsystem is intended to provide support for devices that in some
+sense are analog to digital or digital to analog converters (ADCs, DACs).
+This includes, but is not limited to ADCs, Accelerometers, Gyros, IMUs,
+Capacitance to Digital Converters (CDCs), Pressure Sensors, Color, Light and Proximity Sensors,
+Temperature Sensors, Magnetometers, DACs, DDS (Direct Digital Synthesis), PLLs (Phase Locked Loops),
+Variable/Programmable Gain Amplifiers (VGA, PGA), and RF transceivers. You can use libiio natively
+on an embedded Linux target (local mode), or use libiio to communicate remotely to that same target
+from a host Linux, Windows or MAC over USB or Ethernet or Serial.")))
+
 (define-public liquid-dsp
   (package
     (name "liquid-dsp")