Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build & install SoapySDR on Windows? #446

Open
eabase opened this issue Feb 12, 2025 · 13 comments
Open

How to build & install SoapySDR on Windows? #446

eabase opened this issue Feb 12, 2025 · 13 comments

Comments

@eabase
Copy link

eabase commented Feb 12, 2025

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
Copy link
Author

eabase commented Feb 13, 2025

BUMP

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

Seem #442 could be of interest as well.

@eabase
Copy link
Author

eabase commented Feb 24, 2025

Ok, managed to build the optional SoapyRTLSDR, here:
pothosware/SoapyRTLSDR#79

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

Does anyone, know how I can test this?

@zuckschwerdt
Copy link
Member

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

@eabase
Copy link
Author

eabase commented Feb 25, 2025

They don't have any binary releases and the compile fails. 💩
rxseger/rx_tools#105

@eabase
Copy link
Author

eabase commented Feb 25, 2025

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

@zuckschwerdt
Copy link
Member

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

install(
TARGETS ${SWIG_MODULE_SoapySDR${PYTHON_VERSION}_REAL_NAME}
DESTINATION ${PYTHON_INSTALL_DIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/SoapySDR.py
DESTINATION ${PYTHON_INSTALL_DIR}
)

@eabase
Copy link
Author

eabase commented Feb 26, 2025

@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?

@zuckschwerdt
Copy link
Member

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.

@eabase
Copy link
Author

eabase commented Feb 26, 2025

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!

@zuckschwerdt
Copy link
Member

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.

@eabase
Copy link
Author

eabase commented Mar 3, 2025

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 ?

@guruofquality
Copy link
Contributor

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

@eabase
Copy link
Author

eabase commented Mar 6, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants