Running OpenTAP 9.18, TUI, and Python plugin on Raspberry Pi 4

Today I got OpenTAP 9.18.4 running on my Raspberry Pi 4, with the TUI and the new Python 3.0.0-beta.3 plugin!

Here is a summary of what I had to do to get it running:

  1. Install Raspbian Bullseye on a Raspberry Pi 4. No reason it shouldn’t work on other versions of the Pi or other Linux flavors, with minor tweaks.
  2. Install .NET 6 SDK using the simple instructions at: Install the .NET 6.0 SDK on a Raspberry Pi in Two Easy Steps | by John Mills | Jul, 2022 | Level Up Coding
  3. Clone and build OpenTAP 9.18.4 from source, using the instructions in the README.md
  4. Set environment variables in my ~/.bashrc so the system knows where dotnet and tap are installed
# at the bottom of ~/.bashrc
export TAP_PATH=$HOME/src/opentap/bin/Release
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools:$TAP_PATH
# then reload the settings by running
source ~/.bashrc
  1. Install Python plugin, using the -f option because TAP didn’t seem to like missing dependencies
    tap package install --version beta -f Python
  2. Install TUI plugin, using the -f option because TAP didn’t seem to like missing dependencies
    tap package install --version beta -f TUI
  3. In the Python plugin settings in TAP, set the Python Path to (uses Python 3.9 on this system):
/usr/bin/python
  1. I struggled to figure out what TAP wanted for the Python Library Path. After some sleuthing, I came up with the right .so for my installation.
/usr/lib/aarch64-linux-gnu/libpython3.9.so

After a bit more investigation, I came up with the following Python code that works in both Raspbian and my x64 Mac to find the correct path. Maybe the plugin could run a script like this when the user sets the Python Path and auto-detect the Python Library Path? It would obviously need to be tested on all supported OS’s / bitness / venv’s…

# attempt to find the Python Library Path for current Python
def find_python_library_path():
    import glob 
    import os
    import platform
    import sysconfig
    
    plat = platform.system()
    
    if plat == 'Darwin':
        extension = 'dylib'
    elif plat == 'Linux':
        extension = 'so'
    elif plat == 'Windows':
        extension = 'dll'
    else:
        extension = ''
        
    directory = sysconfig.get_config_var('LIBPL')
    
    files = glob.glob(os.path.join(directory, 'libpython*' + extension))
    
    if len(files) > 0:
        return files[0]
    else:
        return ''

print(find_python_library_path())
  1. I couldn’t get the TUI to actually set the Python Library Path, so I had to manually set it in my $TAP_PATH/settings/Python.xml file
  2. Restart TAP, add the Python Charge step and its instrument, and off it goes!

I did see some odd errors / warnings when running TAP/TUI, but it seemed to recover OK and ran this simple plan!

11 Likes

Hi @alan_copeland,

Thanks for testing it. I am really happy that you got it to work, but I also understand it was not exactly working out of the box.

I’ll be adding this to the list of search paths!

2 Likes

Cool! Would you post an issue ID here so we can find it in release notes when it’s available?

It was a really minor change. It is available in the newest beta.

Btw, the codebase moved to Github.

You can now find the documentation here: docs.opentap.io/OpenTap.Python

@rolf_madsen Also found this package, which was useful today:

My current Python 3.6 on Windows is installed at:
Python path:
C:\Users\acopelan\AppData\Local\Programs\Python\Python310
Python Library path:
C:\Users\acopelan\AppData\Local\Programs\Python\Python310

Nice, but I am afraid we cannot use it, since running this requires us to be able to load python in the first place. But I guess we can try to invoke python from the command line…

We could put it in the documentation to help people with more custom installations,

In any case we should search C:\Users\...\AppData\Local\Programs\Python on windows.

Documentation is a good idea! Also good to include that path.

There is an embeddable Python now on the download page. Have you considered bundling that in a Python plug-in? Maybe a new bundle, then it would provide the whole Python enchilada.