SoapySDR icon indicating copy to clipboard operation
SoapySDR copied to clipboard

How to build & install SoapySDR on Windows?

Open eabase opened this issue 10 months ago • 13 comments

Looking at the page: https://github.com/pothosware/SoapySDR/wiki/BuildGuide

Say that:

add C:\Program Files\SoapySDR\bin to the %PATH%

But: cmake --build my_build_dir --config Release --target install

actually installs into the x86 directory:
C:\Program Files (x86)\SoapySDR

How to build SoapySDR on Windows?

What is the optional swig dependency used for? (How should that be installed?)

I also suggest to fix these to prevent deprecation warnings:

# grep "cmake_minimum_required" CMakeLists.txt

ExampleDriver/CMakeLists.txt:5:cmake_minimum_required(VERSION 2.6)
luajit/CMakeLists.txt:4:cmake_minimum_required(VERSION 3.1.0)
swig/csharp/apps/CMakeLists.txt:1:cmake_minimum_required(VERSION 3.3.0)
swig/python/CMakeLists.txt:4:cmake_minimum_required(VERSION 3.3)
CMakeLists.txt:4:cmake_minimum_required(VERSION 3.3.0)

eabase avatar Feb 12 '25 23:02 eabase

BUMP

How do install the python package after compilation? (Where is it?)

Seem #442 could be of interest as well.

eabase avatar Feb 13 '25 18:02 eabase

Ok, managed to build the optional SoapyRTLSDR, here: https://github.com/pothosware/SoapyRTLSDR/issues/79

Sort of works...but need more testing. (How?)

Does anyone, know how I can test this?

eabase avatar Feb 24 '25 22:02 eabase

rx_sdr from https://github.com/rxseger/rx_tools should work as test tool for any SoapySDR module.

zuckschwerdt avatar Feb 24 '25 23:02 zuckschwerdt

They don't have any binary releases and the compile fails. 💩 https://github.com/rxseger/rx_tools/issues/105

eabase avatar Feb 25 '25 08:02 eabase

BTW. Where exactly is the code that does the Python package installation?

eabase avatar Feb 25 '25 08:02 eabase

Where exactly is the code that does the Python package installation?

https://github.com/pothosware/SoapySDR/blob/6e99da18c4b24129f902a5362ea2adf68abeb1e8/swig/python/CMakeLists.txt#L137-L145

zuckschwerdt avatar Feb 25 '25 09:02 zuckschwerdt

@zuckschwerdt That is not very helpful.

How and where do I do pip install ... to get this package to show up in my pip list?

eabase avatar Feb 26 '25 10:02 eabase

I don't think that SoapySDR is on pypi, so no pip. You just get the swig module and wrapper .py installed to the Python dir.

zuckschwerdt avatar Feb 26 '25 11:02 zuckschwerdt

You just get the swig module and wrapper .py installed to the Python dir.

That's not how it works AFAIK. So how would you import into your python code? If it's not available by the package manager, you can't import (as you suggest in all the example code), with import SoapySDR.

If it's not in pypi, you would (typically) just go to the project directory and do pip install . But that require that you have at least the minimal setup.py (and setup.cfg) and/or pyproject.toml files configured. And you guys don't have any!

  • https://betterscientificsoftware.github.io/python-for-hpc/tutorials/python-pypi-packaging/
  • https://packaging.python.org/en/latest/guides/writing-pyproject-toml/

eabase avatar Feb 26 '25 13:02 eabase

I didn't write any (Python) example code, sorry. I never used the Python bindings. To my understanding you can either install a package from a registry (pypi) or local source (setup.py) -- or just dump the files somewhere into Python's search path.

zuckschwerdt avatar Feb 26 '25 14:02 zuckschwerdt

I can't find this in pypi (as you said). This doesn't make sense at all. :( Can you find someone in this organization that could help? Maybe @guruofquality ?

eabase avatar Mar 03 '25 03:03 eabase

To put the python packages into the search path? You can edit the PYTHONPATH environment variable

There is also a registry way to add to the path, example: https://github.com/pothosware/PothosSDR/blob/master/SetupPython.cmake#L21C1-L24C3

guruofquality avatar Mar 03 '25 13:03 guruofquality

Hi Josh! @guruofquality

Thank you.

I see that you are using HKLM to query paths, but I don't have any Python in that branch, my Python branch is located in HKCU. (And TBH IDK why that is. I surely installed to be available for the entire machine.)

There is also a registry entry called PythonPath with:
C:\lang\Python312\Lib\;C:\lang\Python312\DLLs\.

get_filename_component(PYTHON3_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON3_VERSION}\\InstallPath]" ABSOLUTE)
...
set(PYTHON3_INCLUDE_DIR ${PYTHON3_ROOT}/include)
set(PYTHON3_LIBRARY ${PYTHON3_ROOT}/libs/python${PYTHON3_VERSION_NO_DOT}.lib)
set(PYTHON3_INSTALL_DIR lib/python${PYTHON3_VERSION}/site-packages)

So a few things here, right away.

  • You are mixing Windows and Posix paths. \ vs /, this never ends well..
  • The name is also outdated with the 3. No sane person is still using Python2, so let's avoid using that notation, as it is no longer portable or compatible.
  • Check other windows installs for what registry entries they are using.
  • Consider not using Registry entries at all. Having you Pythin in the path or setting the Python specific environment variables should be enough.
  • Why is PYTHON_INSTALL_DIR not including the PYTHON_ROOT?

So this means that I should have:

PYTHON_ROOT='C:\lang\Python312'
PYTHON_INCLUDE_DIR='C:\lang\Python312\include'          # These are private Python distro includes.
PYTHON_LIBRARY='C:\lang\Python312\libs\python312.lib'   # Not the "python3.lib" or "_tkinter.lib"
PYTHON_INSTALL_DIR='C:\lang\Python312\site-packages'    # Where pip packages go...

However, the middle 2 should not be relevant at all, as nothing should ever be put there, unless they are used for the compilation process, which is not clear at all from any of your CMake files.

Then we have:

  • in .\Lib\<packagename>: private to Python built-ins.
  • in .\Lib\site-packages\<packagename>: we have the __main__.py and __init__.py (package) files

For simplicity let's call the files: A = __init__.py - Contains a Class with the importable name. B = __main__.py - Contains the main entry point.

So AFAIK, in order to be able to use a statement like import SoapySDR, we have to:

  1. Place the 2 files A and B into the <packagename> sub-directory of .\site-packages\.
  2. File A Contains a Class with the importable name:
class SoapySDR:
    def __init__(self, config_file=None):
        config_file = Path(config_file) if config_file is not None else None
        self.config = Configuration(config_file)
    ...
  1. File B contains the import and then main code entry point:
from packagename import SoapySDR
...
if __name__ == "__main__":
    print("The Main code starts here...")

It doesn't seem we have any such Class, or function... So how (and where) did you generate and install these files so that they can be imported with import SoapySDR?

eabase avatar Mar 06 '25 03:03 eabase