diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index b173595..d4eca99 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -38,3 +38,19 @@ jobs: # - name: Test with pytest # run: | # pytest + + test_pi_installer_script: + runs-on: ubuntu-latest + # specify an debian bookworm container + container: + image: debian:bookworm + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - name: Run installer + run: | + # Don't expect this to be root + whoami + source ./install.sh diff --git a/README.md b/README.md index 8eae377..ec64093 100755 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ If you already have this kit, then I hope you find this library and it's informa On a terminal at the Raspberry Pi enter these commands: - curl https://raw.githubusercontent.com/orionrobots/python_usb_robot_arm/main/setup_arm.sh | sudo bash + curl https://raw.githubusercontent.com/orionrobots/python_usb_robot_arm/main/install.sh | sudo bash -I suggest review the setup_arm.sh script above to see what it does. +I suggest review the install.sh script above to see what it does. ## Requirements for Other OS diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..d2f858f --- /dev/null +++ b/install.sh @@ -0,0 +1,42 @@ +#!/bin/env bash +# Raspbian/Debian setup +# Usage +# source ./install.sh [-v ] +# Will activate/create a venv for the installation +# +# -v : Optional, specify a virtual environment folder to install into +# If not specified, uses .venv in the current folder +set -e + +# Doesn't run with sudo, uses sudo for specific commands +sudo apt-get update -y +sudo apt-get install -y python3-libusb1 python3-pip git + +venv_folder=".venv" +# check for the -v flag +while getopts "v:" opt; do + case ${opt} in + v ) + venv_folder=$OPTARG + ;; + \? ) + echo "Usage: source ./install.sh [-v ]" + return 1 + ;; + esac +done + +if [ ! -d "$venv_folder" ]; then + python3 -m venv "$venv_folder" +fi +source "$venv_folder/bin/activate" + +pip3 install git+https://github.com/orionrobots/python_usb_robot_arm + +# cat </etc/udev/rules.d/42-usb-arm-permissions.rules +# SUBSYSTEM=="usb", ATTR{idVendor}=="1267", ATTR{idProduct}=="0000", MODE:="0666" +# END + +# echo "Please reboot for the udev rules to take effect" +echo "To use the library, source the virtual environment with:" +echo " source $venv_folder/bin/activate" diff --git a/setup_arm.sh b/setup_arm.sh deleted file mode 100644 index 9385f37..0000000 --- a/setup_arm.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/env bash -e -# Raspbian setup -apt-get update -y -apt-get install -y python3-libusb1 python3-pip git -pip3 install git+https://github.com/orionrobots/python_usb_robot_arm -cat </etc/udev/rules.d/42-usb-arm-permissions.rules -SUBSYSTEM=="usb", ATTR{idVendor}=="1267", ATTR{idProduct}=="0000", MODE:="0666" -END