How to make command run a python script inside of github part

Hello! I am new to snap (and sort of ubuntu) but excited to use it as it seems like the best packaging system for my application.

For my first snap I am attempting intel’s pyrealsense2 which is a python wrapper for c++ code that interacts with their cameras, it has a pip install as well as a github repo (which contains an example file I want to run) so my yaml is this (nothing else except header and grade/confinement):

parts:
  pyrealsense2:
    source-type: git
    source: https://github.com/IntelRealSense/librealsense.git
    plugin: python
    python-version: python3
    python-packages: 
      - pyrealsense2

should my git and python package be in separate parts?

which to my surprise all snapcrafts and installs fine (minus 1 warning for libusb), however pyrealsense is not like a finished app where you can just run bin/pyrealsense and get it, so setting up an app/command for this like most of the tutorials do does not work and this is where I don’t understand exactly what to do. I want to make a command that simply goes into the directory from the github, specifically: https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python/examples

and runs a python file in this folder. I am just struggling to understand what exactly I need for the path and the rest of the command in this case?

Try this:

parts:
  pyrealsense2:
    plugin: python
    python-version: python3
    python-packages:
      - pyrealsense2

  realsense-examples:
    plugin: dump
    source: https://github.com/IntelRealSense/librealsense.git
    source-subdir: wrappers/python/examples

apps:
  # usage of one of the examples to show how to reference them
  align-depth2color:
    command: python3 $SNAP/align-depth2color.py

This will put all the examples in your snap at the top-level directory (i.e. $SNAP/)

1 Like

Thanks a ton this works!

Just need to get libUSB on now