mjiggidy / adderlib

adderlib is an unofficial python wrapper for the Adder API for use with Adderlink KVM systems.
http://adderlib.readthedocs.io
GNU General Public License v3.0
1 stars 1 forks source link

Some dependency issues #9

Closed eriko-de closed 2 years ago

eriko-de commented 2 years ago

Hey, first of all many thanks for this awesome libary :)

I used it to test and play around with some adderlib devices on a network running a script on a raspberry pi.

When I was using it, I found two minor issues related to dependencies and runtimes:

  1. The 'xmltodict' libary needs to be forced to be <0.13, I'm not an export in python programming, but it seems the version requirement is set in the requirements.txt, when setting up this project, but when installing adderlib via pip, it seems to use the latest version.
  2. When using default python on raspberry pi (version 3.7), you get an error message:
    Traceback (most recent call last):
    File "/usr/local/bin/kvm_switcher.py", line 3, in <module>
    from adderlib import adder
    File "/usr/local/lib/python3.7/dist-packages/adderlib/adder.py", line 13, in <module>
    class AdderAPI:
    File "/usr/local/lib/python3.7/dist-packages/adderlib/adder.py", line 257, in AdderAPI
    group_name:typing.Optional[str]=None) -> AdderChannel:
    TypeError: 'type' object is not subscriptable

    I needed to compile the latest python version (3.10.5 at that time) to have it work.

This is my first python project so maybe there is an easier solution for the issues. Just wanted to share my experiences

mjiggidy commented 2 years ago

Appreciate all the great info! Can you please confirm Raspberry Pi defaults to Python 3.7.3 just so I can recreate the environment exactly?

mjiggidy commented 2 years ago

I have addressed the two issues:

  1. xmltodict recently released version 0.13.0 which breaks the type hinting in adderlib (they are no longer using OrderedDict). Set the required version to 0.12.0 for now; will include support for newer versions of xmltodict in a future release.

  2. Used older-style typing.List type hinting for compatibility with python3.7.x to address the "not subscriptable" error.

These changes are currently available in the py3.7-fixes branch here: https://github.com/mjiggidy/adderlib/tree/py3.7-fixes

@eriko-de If you're comfortable cloning this branch and installing (python3 setup.py install) into the default Raspberry Pi python 3.7 environment, would you mind testing and verifying this fixes your issues before I roll it out to PyPi? Please be sure to remove any previous installations of adderlib or xmltodict first.

Thanks!

mjiggidy commented 2 years ago

Merged the fixes to the master branch and issued v1.0.3 to PyPi. Please let me know if this continues to be an issue.

Thanks!