Git Product home page Git Product logo

Comments (9)

JnyJny avatar JnyJny commented on June 27, 2024

So this is a replay of the previous issue (#17) but now the players are hidapi and Cython rather than my buggy HID wrapper and ctypes. Cython uses a hybrid language that's a combination of Python and C to wrap shared objects and I will have to do some research to find out how it locates shared libraries. The early workaround from #17 (copying files from /opt/local/lib to /usr/local/lib) will likely work in this case too. After research below this is not true.

I'll update as soon as I have a better idea of how Cython works.

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

I did some reading (docs and code) and have improved my understanding of Cython projects and packaging. It appears that cython-hidapi does not need a separate shared object installed to function. I tested this by removing hidapi and installing blycnlight in a virtual environment:

$ brew uninstall hidapi   # sudo port uninstall hidapi should work too
$ mkdir tmp; cd tmp
$ python3 -n venv venv 
$ source venv/bin/activate
$ pip install blynclight
...
$ blync # light turns on green

To be honest this is a tidier solution than my previous implementation, so I really hope we can get this working for you.

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

I'm curious what the output of pip list in that virtual environment with the busted blynclight installed.

In the venv created above, I got this output:

$ pip list
Package    Version
---------- -----------
blynclight 0.8.0
certifi    2020.6.20
chardet    3.0.4
click      7.1.2
hidapi     0.9.0.post3
idna       2.9
pip        20.1.1
requests   2.24.0
setuptools 47.3.1
typer      0.2.1
urllib3    1.25.9

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

Embarrassingly, the 0.8.0 release was built from a feature branch (hid) and not master which may or may not have been completely up-to-date. I've reconciled the two branches and pushed a new release 0.8.2 to PyPI.

from blynclight.

Jaharmi avatar Jaharmi commented on June 27, 2024

I got both the blynclight and luxafaret modules — or at least their CLI tools — to work with the following new venv. I installed only the two "busy light" modules and their requirements, along with updating pip. It looks like Pip installed the new release v0.8.2.

$ pip list
Package    Version
---------- -------------
blynclight 0.8.2
certifi    2020.6.20
chardet    3.0.4
click      7.1.2
hidapi     0.7.99.post21
idna       2.9
luxafaret  1.1.0
pip        20.1.1
requests   2.24.0
setuptools 41.2.0
typer      0.2.1
urllib3    1.25.9
webcolors  1.11.1

There is a conflict between the two "busy light" modules I'm currently using when it comes to hidapi but both appear to work fine with the older version required by luxafaret.

ERROR: blynclight 0.8.2 has requirement hidapi<0.10.0,>=0.9.0, but you'll have hidapi 0.7.99.post21 which is incompatible.

I made no other changes to the compiled libraries installed in my /usr/local/lib and /opt/local/lib directories.

Meanwhile, my errors were in a different venv that contained the following modules. I'd been experimenting with different modules to control my two RGB LED busy lights.

$ pip list
Package        Version
-------------- -------------
appdirs        1.4.4
blynclight     0.8.0
certifi        2020.4.5.2
chardet        3.0.4
click          7.1.2
Flask          1.1.2
Flask-HTTPAuth 4.1.0
gevent         20.6.2
greenlet       0.4.16
hid            1.0.4
hidapi         0.7.99.post21
idna           2.9
itsdangerous   1.1.0
jedi           0.17.0
Jinja2         2.11.2
luxafaret      1.1.0
MarkupSafe     1.1.1
parso          0.7.0
pip            20.1.1
prompt-toolkit 3.0.5
ptpython       3.0.2
Pygments       2.6.1
pyluxa4        1.6
requests       2.23.0
setuptools     41.2.0
typer          0.2.1
urllib3        1.25.9
wcwidth        0.2.4
webcolors      1.11.1
Werkzeug       1.0.1
wheel          0.34.2
zope.event     4.4
zope.interface 5.1.0

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

I think I see a problem in the pip list output: there is a hid and hidapi listed and they both likely provide a 'hid' namespace. I'll have to check, but my gut says that blynclight was expecting to get hidapi's namespace and got the other (which blew up for unrelated reasons. I spent a lot of time trying to figure out where that error message was either in my code or in the trezor/cython-hidapi code).

I can relax the version requirements for hidapi in the packaging for blynclight to see if that helps improve your situation.

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

Yep, I've recreated the error that started this issue. I don't have libhidapi.dyld installed by either ports or brew:

$ pip list
Package    Version
---------- ---------
certifi    2020.6.20
chardet    3.0.4
click      7.1.2
hid        1.0.4
idna       2.9
pip        20.1.1
requests   2.24.0
setuptools 47.3.1
typer      0.2.1
urllib3    1.25.9

$ python3 -c "import hid"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/ejo/tmp/venv/.venv/lib/python3.7/site-packages/hid/__init__.py", line 30, in <module>
    raise ImportError(error)
ImportError: Unable to load any of the following libraries:libhidapi-hidraw.so libhidapi-hidraw.so.0 libhidapi-libusb.so libhidapi-libusb.so.0 libhidapi-iohidmanager.so libhidapi-iohidmanager.so.0 libhidapi.dylib hidapi.dll libhidapi-0.dll

It is my opinion that the Cython hidapi solution is superior by nearly every measure I can think of:

  • tracks libhidapi closely
  • pip install builds a shared object directly used by python
  • does not require the user to install hidapi via [brew|port|apt-get|yum|rpm|whatever]
  • actively developed (by not me)

If you like, I can take a look at the luxafaret code to see about porting to Cython hidapi ( should be trivial ).

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

So I took a look at the Luxafaret project and it seems a little abandoned. I've ordered a LuxaFor flag and it should be here Thursday :) I'll add support to blynclight for the Flag and that will solve having to get our two projects synced enough to not interfere with each other.

from blynclight.

JnyJny avatar JnyJny commented on June 27, 2024

@Jaharmi I've got a new project you might be interested in, busylight-for-humans. It supports both Embrava BlyncLights and Luxafor Flags from the same command-line:

$ busylight list
...
$ busylight supported
Embrava BlyncLight
Luxafor Flag
$ busylight on
$ busylight blink
$ busylight off

This should help you work with your lights while not having to fight dependencies. Let me know how it works for you.

from blynclight.

Related Issues (20)

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.