Having trouble testing conversion to cross compiler

Hi all, I’m having trouble converting the date-time-adapter to cross compile. I got it to build all the artifacts for linux arm/64, x64, and mac for python 3.7, 3.8, and 3.9. I am running python 3.7 on my pi. When I clone https://github.com/wfahle/date-time-adapter to the .webthings/addons folder, it seems to bring everything down, but in the logs I get:

2021-03-10 20:55:46.362 INFO : zwave-adapter: Loading add-on zwave-adapter from /home/node/.webthings/addons/zwave-adapter
2021-03-10 20:55:46.583 INFO : scene-control-adapter: Loading add-on scene-control-adapter from /home/node/.webthings/addons/scene-control-adapter
2021-03-10 20:55:46.769 INFO : thing-url-adapter: Loading add-on thing-url-adapter from /home/node/.webthings/addons/thing-url-adapter
2021-03-10 20:55:46.791 ERROR : date-time-adapter: Traceback (most recent call last):
2021-03-10 20:55:46.792 ERROR : date-time-adapter: File “/home/node/.webthings/addons/date-time-adapter/main.py”, line 12, in
2021-03-10 20:55:46.793 ERROR : date-time-adapter: from pkg.date_adapter import DateTimeAdapter
2021-03-10 20:55:46.795 ERROR : date-time-adapter: File “/home/node/.webthings/addons/date-time-adapter/pkg/date_adapter.py”, line 8, in
2021-03-10 20:55:46.796 ERROR : date-time-adapter: from .date_device import DateTimeDevice # , DateTimeTestDevice
2021-03-10 20:55:46.798 ERROR : date-time-adapter: File “/home/node/.webthings/addons/date-time-adapter/pkg/date_device.py”, line 9, in
2021-03-10 20:55:46.799 ERROR : date-time-adapter: from .util import DT
2021-03-10 20:55:46.806 ERROR : date-time-adapter: File “/home/node/.webthings/addons/date-time-adapter/pkg/util.py”, line 4, in
2021-03-10 20:55:46.809 ERROR : date-time-adapter: import ephem
2021-03-10 20:55:46.820 ERROR : date-time-adapter: ModuleNotFoundError: No module named ‘ephem’
2021-03-10 20:55:46.888 INFO : run-program-adapter: Loading add-on run-program-adapter from /home/node/.webthings/addons/run-program-adapter

What do I need to change so that it finds the ephem (which is in lib, by the way)? Thanks.

By the way, the requirements.txt asks for pyephem, which is what you would pip3 install. The import is import ephem. This all worked as a bootstrap, but trying to do it as a cross compiler makes it fail in test. I don’t want to release without having tested. Do I need to run a build on the local machine after I checkout? I’m new to webthings development and trying to be a good citizen with cross compile.

Ok, I figured it out. For posterity: the linter that is active once you set up your build.yml action upon merging a pull request is very picky. Among other things, it wants you to put all module level imports at the top of the file, specifically in main.py. Trying to be a good citizen, I changed:

import traceback

sys.path.append(path.join(path.dirname(path.abspath(file)), ‘lib’))

from pkg.date_adapter import DateTimeAdapter

to:

import traceback

from pkg.date_adapter import DateTimeAdapter

sys.path.append(path.join(path.dirname(path.abspath(file)), ‘lib’))

This made the linter happy, but caused the above issue. So, I found this reference:


And did this instead:

import traceback

sys.path.append(path.join(path.dirname(path.abspath(file)), ‘lib’))

from pkg.date_adapter import DateTimeAdapter #noqa