neuromodulation / py_neuromodulation

Real-time analysis of intracranial neurophysiology recordings.
https://neuromodulation.github.io/py_neuromodulation/
MIT License
42 stars 9 forks source link

Move LSL lib files inside module directory, increase OS support, fix docs build #328

Closed toni-neurosc closed 3 months ago

toni-neurosc commented 3 months ago

So recently the documentation builds on ReadTheDocs started failing #327 . This happened because a new version of Ubuntu was released (24.04) and there are currently no liblsl binaries in the liblsl repository compatible with this last version. This basically revealed the fact that the "MNE_LSL_LIB" environment variable was not being set properly in the RTD/Sphinx workflow, and MNE-LSL was downloading the library files from the liblsl repo, but the moment Ubuntu updated this stopped working.

This bug was a god-send because it basically revealed a fundamental flaw in the way I set-up the LSL library file addition: I added them at the repository root level, which means that when installing py_neuromodulation as a package, the liblsl directory would not be present in site-packages/py_neuromodulation, which is the reason the environment variable was useless in the RTD workflow.

So this was problem number 1. To fix this, I moved the liblsl directory into the py_neuromodulation directory, so now it will be installed when the package is installed.

Now for problem number 2: There are no liblsl pre-compiled binaries for Ubuntu 24.04 "noble". This was easy, I just installed Ubuntu 24.04 locally and compiled the library myself. I added it to the liblsl directory together with a bunch of other binaries for other OS variants that were present in the liblsl repo and I did not include last time:

windows_32bit
windows_64bit
darwin_i386
darwin_arm
linux_jammy_32bit
linux_jammy_64bit
linux_focal_64bit
linux_bionic_64bit
linux_bookworm_64bit
linux_noble_64bit

So this also fixes the issue of not having support for non-M1/2/3 Apple computers.

timonmerk commented 3 months ago

Amazing @toni-neurosc! Thanks so much!

toni-neurosc commented 3 months ago

Amazing @toni-neurosc! Thanks so much!

Always a pleasure to fix sth that I myself broke 🙃

timonmerk commented 3 months ago

Btw, did you have issues with matplotlib when testing it on Ubuntu? I keep getting this issue about the matplotlib backend:

../../examples/plot_7_lsl_example.py failed leaving traceback:

596 |   597 | Traceback (most recent call last): 598 | File "/home/docs/checkouts/readthedocs.org/user_builds/py-neuromodulation/checkouts/latest/examples/plot_7_lsl_example.py", line 14, in 599 | from py_neuromodulation import ( 600 | File "/home/docs/checkouts/readthedocs.org/user_builds/py-neuromodulation/envs/latest/lib/python3.11/site-packages/py_neuromodulation/init.py", line 10, in 601 | matplotlib.use("tkagg") 602 | File "/home/docs/checkouts/readthedocs.org/user_builds/py-neuromodulation/envs/latest/lib/python3.11/site-packages/matplotlib/init.py", line 1255, in use 603 | plt.switch_backend(name) 604 | File "/home/docs/checkouts/readthedocs.org/user_builds/py-neuromodulation/envs/latest/lib/python3.11/site-packages/matplotlib/pyplot.py", line 418, in switch_backend 605 | raise ImportError( 606 | ImportError: Cannot load backend 'tkagg' which requires the 'tk' interactive framework, as 'headless' is currently running

There are a couple of ideas to fix it but I am still puzzled why this doesn't show up on GH Workflow.. I feel I should develop on Ubuntu as well. There are a lot of issues with providing tests for the three OS...