Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
@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)
- Commands to Light Not Processing HOT 17
- Support PyUSB & HIDAPI
- ear HOT 1
- pip3 install in editable mode doesn't work HOT 1
- Flash not working HOT 3
- Installing on a Raspberry Pi HOT 20
- Control from iOS shortcut application HOT 3
- ImportError: failed to locate hidapi shared object on macOS Catalina HOT 4
- "No such device" error with blync CLI HOT 15
- ship a command line interface and driver script HOT 1
- [QUESTION] Source of COMMAND_LENGTH HOT 3
- RFE: add a udev rule to docs HOT 6
- Candle flicker effect command-line interface.
- Light not recognized. HOT 5
- MacOSX - usb.core.NoBackendError: No backend available when calling BlyncLight.available_lights() HOT 14
- Add an effects package. HOT 1
- Create a simple API server and ship in scripts directory.
- Python version testing with tox
- Relax version requirements for Python from only 3.7 to 3.5 or better HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blynclight.