abudden / OctoPrint-USBRelayControl

Plugin for OctoPrint for controlling HID-based USB relays
GNU Affero General Public License v3.0
11 stars 2 forks source link

Fails to install in docker container #1

Open kylegordon opened 2 years ago

kylegordon commented 2 years ago

Unfortunately this plugin fails to install when using Octoprint 1.6.1 in Docker. It seems to be requiring libusb inside the docker container, which is understandable. The relevant bit of the installation log is...


Created wheel for OctoPrint-USBRelayControl: filename=OctoPrint_USBRelayControl-1.0.0-py2.py3-none-any.whl size=37660 sha256=a460d7740b7eca7ec08a8495b05e2258419f2e51cb3fb82f26c6c5f86c9e0970
Stored in directory: /tmp/pip-ephem-wheel-cache-a6bw93sy/wheels/84/78/6c/b2d17f5dbce1c9ef3818a6d7d2844500db890bc89d73a70564
Building wheel for hidapi (setup.py): started
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ziihwxpx
cwd: /tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/
Complete output (19 lines):
running bdist_wheel
running build
running build_ext
skipping 'hid.c' Cython extension (up-to-date)
cythoning hidraw.pyx to hidraw.c
/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/.eggs/Cython-0.29.28-py3.8.egg/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/hidraw.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'hid' extension
creating build
creating build/temp.linux-armv7l-3.8
creating build/temp.linux-armv7l-3.8/hidapi
creating build/temp.linux-armv7l-3.8/hidapi/libusb
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ihidapi/hidapi -I/usr/include/libusb-1.0 -I/usr/local/include/python3.8 -c hid.c -o build/temp.linux-armv7l-3.8/hid.o
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ihidapi/hidapi -I/usr/include/libusb-1.0 -I/usr/local/include/python3.8 -c hidapi/libusb/hid.c -o build/temp.linux-armv7l-3.8/hidapi/libusb/hid.o
hidapi/libusb/hid.c:47:10: fatal error: libusb.h: No such file or directory
#include <libusb.h>
^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for hidapi
Building wheel for hidapi (setup.py): finished with status 'error'
Running setup.py clean for hidapi
Successfully built OctoPrint-USBRelayControl
Failed to build hidapi
Installing collected packages: hidapi, OctoPrint-USBRelayControl
Running setup.py install for hidapi: started
Running setup.py install for hidapi: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tp2574a4/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /octoprint/plugins/include/python3.8/hidapi
cwd: /tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/
Complete output (17 lines):
running install
running build
running build_ext
skipping 'hid.c' Cython extension (up-to-date)
skipping 'hidraw.c' Cython extension (up-to-date)
building 'hid' extension
creating build
creating build/temp.linux-armv7l-3.8
creating build/temp.linux-armv7l-3.8/hidapi
creating build/temp.linux-armv7l-3.8/hidapi/libusb
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ihidapi/hidapi -I/usr/include/libusb-1.0 -I/usr/local/include/python3.8 -c hid.c -o build/temp.linux-armv7l-3.8/hid.o
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ihidapi/hidapi -I/usr/include/libusb-1.0 -I/usr/local/include/python3.8 -c hidapi/libusb/hid.c -o build/temp.linux-armv7l-3.8/hidapi/libusb/hid.o
hidapi/libusb/hid.c:47:10: fatal error: libusb.h: No such file or directory
#include <libusb.h>
^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-pe4bup6w/hidapi_c1ae9878b0dd4a439704078caff1fca2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tp2574a4/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /octoprint/plugins/include/python3.8/hidapi Check the logs for full command output.
Error!
Could not parse output from pip, see plugin_pluginmanager_console.log for generated output

This problem may go away in later versions of Octoprint - I haven't upgraded from 1.6.1 yet. Please just close this issue if that's the case :-)

abudden commented 2 years ago

Sadly there's not much I can do about this and it's the reason for this bit in the README:

The module depends on the hidapi module, which should be installed automatically. If you have any issues, try installing these packages before installing the plugin:

sudo apt-get install python3-dev libusb-1.0-0-dev libudev-dev

You'll also need to make sure that the USB relay can be controlled without root privileges.

For example, edit /etc/udev/rules.d/99-usbrelay.rules and add this line:

SUBSYSTEM=="usb", ATTR{idVendor}=="16c0", ATTR{idProduct}=="05df", MODE="777"

Octoprint (understandably) doesn't provide any means of installing system packages as part of the plugin install. Without those extra packages installed, there's no way to install hidapi and hence no way to install the plugin.

kylegordon commented 2 years ago

@abudden totally understandable! I installed libusb-dev and libudev-dev in my docker container and have the plugin working now, so have created the above linked PR in the Octoprint-docker repository. Let's see how that goes :-)

abudden commented 2 years ago

@abudden totally understandable! I installed libusb-dev and libudev-dev in my docker container and have the plugin working now, so have created the above linked PR in the Octoprint-docker repository. Let's see how that goes :-)

That's a great idea, thanks. I might try and make sense of the octopi source code to see how hard it would be to get those packages installed there as well.

Note that you'll still have to do the udev stuff or it'll fail (without a helpful error message!)