×

INDI Library v1.9.8 Released (29 Sep 2022)

Bi-monthly INDI Library released with new drivers and bug fixes.

Problem importing PyIndi

  • Posts: 94
  • Thank you received: 10

Replied by dolguldur on topic Problem importing PyIndi

There seems to be other things that are not right with 1.8.8 and 1.8.9:
Here is what I get trying to install pyindi with version older than 0.2.6 ie 0.2.5 and earlier :

<code>pip install pyindi-client==0.2.5; python -c "import PyIndi"
</code>
:
At this line, there is a macro:
<code>class Property
{
DECLARE_PRIVATE(Property)
public:
Property();
</code>

The macro is defined in indiutility.h
<code>#define DECLARE_PRIVATE(Class) \
inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(getPtrHelper(d_ptr)); } \
inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(getPtrHelper(d_ptr)); } \
friend class Class##Private;
</code>

I think this is breaking swig

From github, it looks that those changes where made by pawel soja, and I am not sure wether the tests from the build platform includes swig compatibility (ie, building python bindings before accepting the PR), I doubt it:
github.com/indilib/indi/blob/master/libs/indibase/indiutility.h
Last edit: 1 year 8 months ago by dolguldur.
1 year 8 months ago #66918

Please Log in or Create an account to join the conversation.

  • Posts: 931
  • Thank you received: 127
Maybe some comments:
There are other programs/packages that have problems with pip-installed stuff. E.g., python-opencv installs binary libraries that will not run on recent systems (Tumbleweed, Fedora 33, Ubuntu 20.??). Then trying to run python code that imports it will crash. Does your 'pip install' also bring such precompiled .so libs?

I tried to install pyindi-client here (openSUSE Tumbleweed) using pip, but I cant even do that. It will download version 0.2.6 tar file and try to run the setup.py. First had to install swig (4.0.2), but then compiling will fail with
    indiclientpython_wrap.cpp: In function ‘PyObject* _wrap_Property_getNumber(PyObject*, PyObject*)’:
    indiclientpython_wrap.cpp:22067:3: error: ‘PropertyView’ was not declared in this scope; did you mean ‘INDI::PropertyView’?
    22067 |   PropertyView< INumber > *result = 0 ;

This tries to compile against libindi-1.8.9-16_gd6e9d74a. Full install log attached, if someone's interested.
openSUSE Tumbleweed KStars git INDI git
GPDX+EQMOD, CEM60EC, ASI2600/1600/290mini+EFW+EAF
1 year 8 months ago #66955
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 226
  • Thank you received: 88

Replied by Jean-Luc on topic Problem importing PyIndi

I just tried to build pyindi-client with latest indi core commit on up-to-date Ubuntu 20.04. That compiles fine but the testindiclient.py script crashes when trying to iterate over a switch property:
```
elif p.getType()==PyIndi.INDI_SWITCH:
tpy=p.getSwitch()
for t in tpy:
TypeError: 'SwigPyObject' object is not iterable
pure virtual method called
```
It seems that Property get* methods are pure virtual. Will have a more precise look to that later.
1 year 7 months ago #67034

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0

Replied by James on topic Problem importing PyIndi

Getting similar problems trying to use even basic basic PyIndi stuff - connection works but trying to update parameters I get the same subscriptable error.
None of the example scripts in the docs work except the basic "import, connect, and do nothing" one.

So yeah, PyIndi appears completely broken right now on 1.8.9. I've been trying to write a Rust INDI client which can provide a Python binding because the current state of PyIndi isn't great (and on other platforms like Windows it's a challenge), but it's a lot of effort to get that working.
1 year 6 months ago #68892

Please Log in or Create an account to join the conversation.

  • Posts: 1029
  • Thank you received: 301

Replied by Eric on topic Re:Problem importing PyIndi

First, go python3. Then, because there are changes in the structure of indi in progress, please be patient with the maintainer of pyindi, or offer to debug more deeply. Thanks!

-Eric
HEQ5-Pro - Atik 314E - Orion ED80T - DMK21 on Orion 50mm
DIY 3D-printed Moonlite and FWheel RGB/LPR
KStars and indiserver on two Atom 1.6GHz 1GB RAM Linux, VPN remote access
1 year 6 months ago #68894

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0

Replied by James on topic Re:Problem importing PyIndi

I'm using Python 3.

I am completely up for pitching in on pyindi if I can figure out how - I just wanted to confirm that the issue seen above was not isolated and was current.

My main gripe with pyindi is the documentation - if there are major changes underway that's okay, I know docs are often the last thing to get updated (being a maintainer for some OSS myself) but it doesn't help newbies (like me!) coming into an ecosystem if the basic examples explode with the "correct" config/setup/etc.

Edit: In the spirit of debugging "more deeply" - the issue appears that the attrs (value) referenced in the docs on the property returned by a device.getNumber() call (and from the looks of it, other similar calls) don't exist any more. The returned object is a INDI::PropertyView SWIG wrapper which has essentially no attributes or functions outside of the generic SWIG ones. This means you can't alter e.g. an exposure time value before returning it with sendNewNumber.

Without modifying the value, the sendNewNumber function additionally crashes with the following:
Traceback (most recent call last):
  File "allsky/allsky.py", line 91, in <module>
    asc.sendNewNumber(camera_exposure)
  File "/usr/local/lib/python3.7/dist-packages/PyIndi.py", line 1147, in sendNewNumber
    return _PyIndi.BaseClient_sendNewNumber(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'BaseClient_sendNewNumber'.
  Possible C/C++ prototypes are:
    INDI::BaseClient::sendNewNumber(INumberVectorProperty *)
    INDI::BaseClient::sendNewNumber(char const *,char const *,char const *,double)
Last edit: 1 year 6 months ago by James.
1 year 6 months ago #68896

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 32
This happened a lot before, and it's definitely gonna happen again.
As much as I appreciate the pyindi-client project, it's essentially just a workaround for automatic API generation.

I have to wonder if it wouldn't just be easier to write a native python client for the XML protocol, or possibly a c++ python wrapper exposing a simplified version of the API...
The following user(s) said Thank You: dolguldur
1 year 6 months ago #69365

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0

Replied by James on topic Re:Problem importing PyIndi

I've been working on a Rust-native client that has no dependency on libindi, specifically because I want something portable; in theory it would be quite easy to provide a Python extension with the Rust backend.

Having said that, a pure Python client would be much easier to write (I'm struggling with INDI because of the poor state of XML parsers in Rust) and in theory to maintain given the wider Python userbase. For client authoring it'd certainly be easier to work with. I'm writing this purely to drive an all-sky camera and that'll be shipping images off to a neural net/CV stuff for image segmentation, and Python's a native of that sort of thing.
1 year 6 months ago #69371

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 32
I would be afraid that the Rust-based python extension would have similar problem..
Not that I don't trust your work, but given that not many people know Rust, it would be difficult to find someone helping you maintain it :\

Ideally, the best solution would be a simplified JSON interface written in C++ directly into the INDI server. That way, writing a client for python, or indeed any other language, would be much much simpler
1 year 6 months ago #69372

Please Log in or Create an account to join the conversation.

  • Posts: 94
  • Thank you received: 10
There seems to be already some work made in that direction:
github.com/geehalel/npindi
github.com/MMTObservatory/indiclient/tree/master/indiclient

I definitely agree that a full python solution would eventually be the best choice for long term support.
Cases where people will write exotic macros here and there that will probably continue break swig (without even considering the static binary dependency for the client)
Last edit: 1 year 6 months ago by dolguldur.
1 year 6 months ago #69414

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 32
That is good to know!
I was actually about to start my own implementation, but if I can find the time I might try to contribute to one of these.
geehalel implementation seems more mature, but also inactive in a couple of years.
@Jean-Luc do you have any insight on this?
is there a way to tag someone in this forum? 
Last edit: 1 year 6 months ago by Marco Gulino.
1 year 6 months ago #69420

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 14

The macro is not exotic and it was never a problem. The error was in using a macro without a proper include in pyindi-client.
Most of the problems with PyIndi are related to the work on the INDI Library to keep the interface in the future without rebuilding dependencies.
Also, high-level functions that facilitate the development process are implemented.

I am currently creating automatic builds for Linux / MacOS. If you like, I can add additional tests for pyindi-client.
The following user(s) said Thank You: dolguldur
1 year 6 months ago #69460

Please Log in or Create an account to join the conversation.

Time to create page: 1.008 seconds