Skip to content

Commit

Permalink
Add multiplatform opalkelly SDK files, got mac working, committing so…
Browse files Browse the repository at this point in the history
… i can work on linux
  • Loading branch information
sneakers-the-rat committed Oct 30, 2023
1 parent 982fe41 commit 209b560
Show file tree
Hide file tree
Showing 24 changed files with 11,638 additions and 4 deletions.
33 changes: 33 additions & 0 deletions miniscope_io/vendor/opalkelly/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# OpalKelly FPGA SDK

See documentation here: https://docs.opalkelly.com/fpsdk/frontpanel-api/programming-languages/

## Files

The Python API distribution includes the files listed below:

- `ok.py`
- `_ok.pyd` – Windows, architecture-specific for 32-bit/64-bit
- `_ok.so` – Linux, Mac OS, architecture-specific for 32-bit/64-bit
- `okFrontPanel.dll` – Windows, architecture-specific for 32-bit/64-bit
- `libokFrontPanel.so` – Linux, Mac OS, architecture-specific for 32-bit/64-bit
- `okimpl_fpoip.dll` – (optional) Windows, architecture-specifc DLL used to provide FPoIP functionality
- `okimpl_fpoip.so` – (optional) Linux, architecture-specifc DLL used to provide FPoIP functionality

## Changes

### Mac

The documentation suggests that all one needs to do is add the folders to
`DYLD_LIBRARY_PATH`, but unfortunately that doesn't work because they have hard-coded
the location to search for the dylib as `@rpath/libokFrontPanel.dylib` and
then set `rpath` to some weird directory on their build server.

So instead we modify the import location in `_ok.so` like:

```bash
install_name_tool -change \
@rpath/libokFrontPanel.dylib \
@loader_path/libokFrontPanel.dylib \
miniscope_io/vendor/opalkelly/mac/_ok.so
```
26 changes: 26 additions & 0 deletions miniscope_io/vendor/opalkelly/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pdb
import sys
from pathlib import Path
import os
import subprocess

def patch_env_path(name:str, value:str):
val = os.environ.get(name, None)
if val is None:
val = value
else:
val = ':'.join([val, value])
os.environ[name] = val

base_path = Path(__file__).parent.resolve()
if sys.platform == 'darwin':
from miniscope_io.vendor.opalkelly.mac.ok import *

elif sys.platform.startswith('linux'):
# Linux
pass
elif sys.platform.startswith('win'):
# Windows
pass
else:
raise ImportError('Dont know what operating system you are on, cant use OpalKelly')
1 change: 0 additions & 1 deletion miniscope_io/vendor/opalkelly/lib/_ok.so

This file was deleted.

1 change: 0 additions & 1 deletion miniscope_io/vendor/opalkelly/lib/libokFrontPanel.so

This file was deleted.

1 change: 0 additions & 1 deletion miniscope_io/vendor/opalkelly/lib/ok.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 209b560

Please sign in to comment.