ideoforms / AbletonOSC

Control Ableton Live 11 via Open Sound Control (OSC)
MIT License
426 stars 70 forks source link

Import errors on MacOS #21

Closed segefjord closed 2 years ago

segefjord commented 2 years ago

I'm having trouble running the code outside of Ableton. The python compiler embedded in Ableton seems to load the code just fine, but trouble is when i try to fire a pytest or run any modules just by python [module]

I'm using pyenv and virtualenv, so it's a completely clean and isolated environment.

The problem seems to be import errors

I get a bunch of errors very similar to the one i dumped down below. It seems to be related to relative imports.

Terminal output

python version: 3.11.0 pytest version: 7.2.0

MacOS Catalina 10.15.7


_____________________________________ ERROR collecting tests/test_track.py _____________________________________
ImportError while importing test module '/Users/ferry/dev/seed/remote/AbletonOSC/tests/test_track.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../.pyenv/versions/3.11.0/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/__init__.py:4: in <module>
    from ..client import AbletonOSCClient, TICK_DURATION
client/__init__.py:1: in <module>
    from .client import AbletonOSCClient, TICK_DURATION
client/client.py:3: in <module>
    from pythonosc.udp_client import SimpleUDPClient
E   ModuleNotFoundError: No module named 'pythonosc'
ideoforms commented 2 years ago

You won't be able to run any of the internal modules outside of Ableton, because their functionality all relies on the ableton.v2 module and Live objects, which are both internal to Live. They are all only really intended to run as part of the control script, which then receives control messages via OSC.

Regarding running the unit tests: I realised that these inadvertently relied on the system having pythonosc installed, which wasn't my intention. Have just pushed a commit that adds . to PYTHONPATH, so that if you run pytest from the top-level directory, it should be able to find and import pythonosc OK. Let me know if that works!

segefjord commented 2 years ago

Oh that's fine. Btw i get a different amount of passed tests when using the internal pythonosc module, and installing the system level one with pip XD Also not all tests are passing - i was looking in the contribution guide and noticed this is required. But are we just rolling with failing tests, or am i doing something wrong still? 😂 btw no judgement, just trying to keep up with you<3

ideoforms commented 2 years ago

Thanks @ferry-creator, it looks like this was a knock-on effect from the above fix - now pushed an update that resolves it (but make sure you run with a fresh empty instance of Live). I try to ensure all of the tests are passing, although I have noticed that occasaionally one or two sporadically fail probably due to some small indeterminacies due to timing.

Let me know if they all pass for you after the above fix!

segefjord commented 2 years ago

Okay, then maybe something is wrong on my system / or i need to write a fix for the framework to get it working on my system.

Ableton Live V11.1.5 I'm testing on a fresh instance of Live everytime as requested in CONTRIBUTING.md :-)

On my system the following tests fail consistently

tests/test_application.py ..
tests/test_clip.py .FFFF.
tests/test_song.py .........................
tests/test_track.py ...F......

(5 tests fail in total)

Your recent push did solve 2 failing tests tho, before the recent commit i got 2 additional failing tests on test_track.py.

tests/test_track.py ...F...F.F

So it did fix something :D Should i attempt a fix for the rest with a PR?

segefjord commented 2 years ago

Interesting note: when i remove all cache folders (__pycache__, .pytest_cache) i get 8 failing tests. It goes back to 5 failing tests after running a second time, and then it's consistent at 5 failed tests.

ideoforms commented 2 years ago

Yep, I'd definitely welcome suggested fixes, thanks!