GithubHelp home page GithubHelp logo

pothosware / pothospython Goto Github PK

View Code? Open in Web Editor NEW
7.0 18.0 5.0 158 KB

Python bindings for the Pothos framework

Home Page: https://github.com/pothosware/PothosPython/wiki

License: Boost Software License 1.0

CMake 10.48% Python 12.18% C++ 77.33%
pothos python python-bindings dataflow pothos-framework

pothospython's Introduction

Python bindings for the Pothos framework

Documentation

Dependencies

  • Pothos library
  • Python development libraries and headers (2.7 or 3.*)
  • Numpy is a runtime dependency for the Pothos Python module

Building

configure, build, and install with CMake

Layout

  • The root directory contains a Pothos::ProxyEnvironment overload that can call into the Python C API.
  • The Pothos/ directory contains a python module that:
    • Provides access to a Pothos::ProxyEnvironment through Python
    • Pythonic API wrapper for Pothos::Block class

Licensing information

Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

pothospython's People

Contributors

guruofquality avatar ncorgan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pothospython's Issues

"error: call of overloaded 'call(const char [12], int)' is ambiguous" using gcc10

Pothos fails to build on openSUSE Tumbleweed with recent gcc10 versions.

$ gcc --version
gcc (SUSE Linux) 10.2.1 20200825 [revision c0746a1beb1ba073c7981eb09f55b3d993b32e5c]
...
[  992s] cd /home/abuild/rpmbuild/BUILD/pothos-0.7.0/build/python && /usr/bin/c++ -DPOCO_ENABLE_CPP11 -DPOCO_ENABLE_CPP14 -DPOCO_HAVE_FD_EPOLL -DPOCO_OS_FAMILY_UNIX -DPOCO_UNBUNDLED -DPythonSupport_EXPORTS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_S
AFE -D_XOPEN_SOURCE=500 -I/home/abuild/rpmbuild/BUILD/pothos-0.7.0/include -I/usr/include/python3.8 -I/usr/include/nlohmann -I/home/abuild/rpmbuild/BUILD/pothos-0.7.0/build/python -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-ta
bles -fstack-clash-protection -Werror=return-type -flto=auto -DNDEBUG -fvisibility-inlines-hidden -O2 -g -DNDEBUG -fPIC -Wno-unused-local-typedefs -Wall -Wextra -Wnon-virtual-dtor -fvisibility=hidden -std=gnu++14 -o CMakeFiles/PythonSupport.dir/PythonInfo.cpp.o -c /home/abui
ld/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp: In function 'std::string __getPythonInfoJSON()':
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:27:69: error: call of overloaded 'call(const char [12], int)' is ambiguous
[  993s]    27 |     versionInfo["Major"] = sysVersionInfo.call<int>("__getitem__", 0);
[  993s]       |                                                                     ^
[  993s] In file included from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy.hpp:14,
[  993s]                  from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:5:
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:77:12: note: candidate: 'ReturnType Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ReturnType = int; ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    77 | ReturnType Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |            ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:84:7: note: candidate: 'Pothos::Proxy Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    84 | Proxy Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |       ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:28:69: error: call of overloaded 'call(const char [12], int)' is ambiguous
[  993s]    28 |     versionInfo["Minor"] = sysVersionInfo.call<int>("__getitem__", 1);
[  993s]       |                                                                     ^
[  993s] In file included from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy.hpp:14,
[  993s]                  from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:5:
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:77:12: note: candidate: 'ReturnType Pothos::Proxy::call(const string&, ArgsType&& ...)
 const [with ReturnType = int; ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    77 | ReturnType Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |            ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:84:7: note: candidate: 'Pothos::Proxy Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    84 | Proxy Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |       ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:29:69: error: call of overloaded 'call(const char [12], int)' is ambiguous
[  993s]    29 |     versionInfo["Patch"] = sysVersionInfo.call<int>("__getitem__", 2);
[  993s]       |                                                                     ^
[  993s] In file included from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy.hpp:14,
[  993s]                  from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:5:
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:77:12: note: candidate: 'ReturnType Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ReturnType = int; ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    77 | ReturnType Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |            ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:84:7: note: candidate: 'Pothos::Proxy Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    84 | Proxy Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |       ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:31:70: error: call of overloaded 'call(const char [12], int)' is ambiguous
[  993s]    31 |     versionInfo["Serial"] = sysVersionInfo.call<int>("__getitem__", 4);
[  993s]       |                                                                      ^
[  993s] In file included from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy.hpp:14,
[  993s]                  from /home/abuild/rpmbuild/BUILD/pothos-0.7.0/python/PythonInfo.cpp:5:
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:77:12: note: candidate: 'ReturnType Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ReturnType = int; ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    77 | ReturnType Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |            ^~~~~
[  993s] /home/abuild/rpmbuild/BUILD/pothos-0.7.0/include/Pothos/Proxy/ProxyImpl.hpp:84:7: note: candidate: 'Pothos::Proxy Pothos::Proxy::call(const string&, ArgsType&& ...) const [with ArgsType = {int}; std::string = std::__cxx11::basic_string<char>]'
[  993s]    84 | Proxy Proxy::call(const std::string &name, ArgsType&&... args) const
[  993s]       |       ^~~~~
[  994s] make[2]: *** [python/CMakeFiles/PythonSupport.dir/build.make:215: python/CMakeFiles/PythonSupport.dir/PythonInfo.cpp.o] Error 1
[  994s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/pothos-0.7.0/build'
[  994s] make[1]: *** [CMakeFiles/Makefile2:2231: python/CMakeFiles/PythonSupport.dir/all] Error 2
[  994s] make[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/pothos-0.7.0/build'
[  994s] make: *** [Makefile:163: all] Error 2

full buildlog:
pothos-openSUSE-Tumblweed-buildlog.txt

Python3.8 and up linker issues

Python modules should no longer get linked to libpython for 3.8 and above. Symbols are late loaded. However the pothos module still needs to be linked against libpython, but its not getting filled in by the usual library flags.

Inconsistent behavior when calls are registered in Python

I'm not sure if this is an issue with the ProxyEnvironment infrastructure itself or a bug on the Python layer, but I'll put it here, since this is where I'm running into it.

When a Pothos::Proxy containing a Python block has call() invoked that links to a function implemented in Python, the proxy environment takes care of this and calls the Python function. This works as expected in my C++ unit tests, but when I implement overlay() in a Python Pothos.Block subclass, PothosFlow doesn't call into it. This appears to be a typical proxy call, so the behavior should be the same.

This also becomes an issue with registerProbe(). When I register a probe called "lastValue", the signal "lastValueTriggered" and slot "probeLastValue" are created. However, when I trigger "probeLastValue", I get an error from Pothos::Block::opaqueCall* saying the method doesn't exist in the registry.

Be pythonic when API calls use Pothos::Object

It looks like calls that use Pothos::Object rather than an explicit data type (like input port pop message) don't convert into the native python object when applicable or have a way to do this, it stays as a proxy of the Pothos::Object(). The conversion support is in there, we just have to make it happen.

block registration installation tools

Installation tools provide a CMake macro/function to

  • install python sources
  • Compile a module to:
    • Register a block in the registry that can construct the python block
    • Register documentation from the python block

pass pure PyObjects between blocks

When passing message between python blocks, we dont need to convert into Object, the PyObject could be kept in the Proxy. Consider this in general for the async message API, passing proxies in general.

python logger object that calls back into poco

Complete the log integration aspect of the python bindings by providing a way for python blocks to use the python logging api to log back into the poco logging subsystem. Think about the reverse direction as well.

Import Pothos module fails

Hi,

I installed Pothosware using the Windows installer several weeks ago and have been using the blocks with my RTL-SDR. That's been going well so I wanted to try creating some of my own Python processing blocks. I'm trying to start with the Adder example to get the basics down.

When I try to import Pothos, I get an ImportError - "no module named Pothos". I checked my sys.path and it includes C:\Program Files\PothosSDR\lib\site-packages\Pothos (which I think is the correct folder). I am using the Anaconda Python 2.7 distribution and the Spyder IDE create & run my Python code. Other Python imports (like numpy) work just fine.

I had a similar issue when I tried to import Soapy-SDR. So I think I am missing something very basic here. Do I need to download and build the Pothos Python from source? I have CMake and Visual Studio 15. I am pretty new at using CMake so instructions would be helpful. :)

Thanks,
Jim Davis

Pythonic wrapper for Topology class

Lets replace this:

env = Pothos.ProxyEnvironment("managed")
topology = env.findProxy('Pothos/Topology').make()

With this:

class Topology:
 ...etc...

topology = Topology()
  • And connect/disconnect should handle integer port names as well

Override PYTHON_INSTALL_DIR for windows

We would like to specify the install path on windows to include the python version. The default install path reported by python lacks the python version name in the directory.

'module' object has no attribute 'implementation'

PothosUtil --device-info=python
>>> Querying device info: /devices/python/info
Proxy Exception Message: 'module' object has no attribute 'implementation'

The GUI needs better reporting: PothosFlow.SystemInfoTree: Failed to query system info tcp://[::1] - Proxy Exception Message: Proxy Exception Message: 'module' object has no attribute 'implementation' -- this doesnt tell us which device was involved

Currently no way to get high-value uint64 values from Python to C++

A current limitation of the Proxy infrastructure is that a specific target-language type can only be converted to a single C++ type. This poses an issue with Python's int or long types. Given the previously mentioned limitation, the conversion back to C++ is implemented as returning a long long.

This means that numbers that are in the range of unsigned long long that aren't in the range of long long cannot accurately be returned to C++, even though internal to the blocks, NumPy supports using these types.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.