From 876ae0f88a0f11d047b24d78617841e1fda49897 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:08:26 +0100 Subject: [PATCH 01/17] fix: imporved install script --- .../workflows/build-and-test-containers.yml | 35 +++ docs/debian:bookworm/Containerfile | 15 ++ docs/install_depthai.sh | 199 ++++-------------- docs/requirements_mkdoc.txt | 2 - docs/ubuntu:jammy/Containerfile | 15 ++ docs/ubuntu:latest/Containerfile | 15 ++ 6 files changed, 122 insertions(+), 159 deletions(-) create mode 100644 .github/workflows/build-and-test-containers.yml create mode 100644 docs/debian:bookworm/Containerfile mode change 100644 => 100755 docs/install_depthai.sh delete mode 100644 docs/requirements_mkdoc.txt create mode 100644 docs/ubuntu:jammy/Containerfile create mode 100644 docs/ubuntu:latest/Containerfile diff --git a/.github/workflows/build-and-test-containers.yml b/.github/workflows/build-and-test-containers.yml new file mode 100644 index 000000000..7af9afaee --- /dev/null +++ b/.github/workflows/build-and-test-containers.yml @@ -0,0 +1,35 @@ +name: Build and Test viewer on Linux + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + container: + - docs/debian:bookworm + - docs/ubuntu:jammy + - docs/ubuntu:latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build container + run: | + cd ${{ matrix.container }} + docker build -t test-${{ matrix.container }} -f Containerfile . + + - name: Run container + run: | + docker run --rm test-${{ matrix.container }} + + - name: Check exit status + run: echo "Container ${{ matrix.container }} exited successfully" diff --git a/docs/debian:bookworm/Containerfile b/docs/debian:bookworm/Containerfile new file mode 100644 index 000000000..f086f04d2 --- /dev/null +++ b/docs/debian:bookworm/Containerfile @@ -0,0 +1,15 @@ +FROM debian:bookworm + +WORKDIR /home/tester + +# Copy script into the container +COPY ../install_depthai.sh /home/tester/install_depthai.sh + +# Make script executable +RUN chmod +x /home/tester/install_depthai.sh + +# Install dependencies (modify if needed based on script requirements) +RUN apt update && apt install -y bash sudo + +# Run the script when the container starts +CMD ["/home/tester/install_depthai.sh"] diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh old mode 100644 new mode 100755 index e36ee888a..da1c6dc30 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -1,122 +1,20 @@ #!/bin/bash +set -e -APP_NAME="depthai" -WORKING_DIR_NAME="Luxonis" -WORKING_DIR="$HOME/$WORKING_DIR_NAME" -mkdir "$WORKING_DIR" -install_path="" -path_correct="false" - -trap 'RET=$? ; echo -e >&2 "\n\x1b[31mFailed installing dependencies. Could be a bug in the installer or unsupported platform. Open a bug report over at https://github.com/luxonis/depthai - exited with status $RET at line $LINENO \x1b[0m\n" ; exit $RET' ERR - -while [ "$path_correct" = "false" ] -do - echo "" - echo 'ENTER absolute installation path for depthai or leave empty and default path: $HOME will be used.' - read -e install_path < /dev/tty - echo "" - - if [ "$install_path" = "" ]; then - echo "Using default installation path: $WORKING_DIR" - mkdir -p "$WORKING_DIR" - else - echo "Using given installation path: $install_path" - WORKING_DIR="$install_path" - fi +VENV_PATH=".local/share/virtualenvs" - if [ -d "$WORKING_DIR" ]; then - echo "Directory: $WORKING_DIR is OK" - path_correct="true" - else - echo "Directory: $WORKING_DIR is not valid. Try again!" - fi -done - -DEPTHAI_DIR="$WORKING_DIR/$APP_NAME" -VENV_DIR="$WORKING_DIR/venv" -ENTRYPOINT_DIR="$DEPTHAI_DIR/entrypoint" - -# Get Python version or find out that python 3.10 must be installed -python_executable=$(which python3) -python_chosen="false" -install_python="false" -python_version=$(python3 --version) -python_version_number="" -if [[ "$python_version" != 'Python'* ]]; then - python_version="" -fi -echo "" - -# check default python version, offer it to the user or get another one -while [ "$python_chosen" = "false" ] -do - if [[ "$python_version" == "" ]]; then - echo "No python version found." - echo "Input path for python binary, version 3.8 or higher, or leave empty and python 3.10 will be installed for you." - echo "Press ENTER key to continue" - read -e python_binary_path < /dev/tty - # python not found and user wants to install python 3.10 - if [ "$python_binary_path" = "" ]; then - install_python="true" - python_chosen="true" - fi - else - # E.g Python 3.10 -> nr_1=3, nr_2=10, for Python 3.7.5 -> nr_1=r, nr_2=7 - nr_1="${python_version:7:1}" - nr_2=$(echo "${python_version:9:2}" | tr -d -c 0-9) - echo "Python version: $python_version found." - if [ "$nr_1" -gt 2 ] && [ "$nr_2" -gt 7 ]; then # first two digits of python version greater then 3.7 -> python version 3.8 or greater is allowed. - echo "If you want to use it for installation, press ENTER key, otherwise input path to python binary." - echo "Press ENTER key to continue" - read -e python_binary_path < /dev/tty - # user wants to use already installed python whose version is high enough - if [ "$python_binary_path" = "" ]; then - python_chosen="true" - fi - else - echo "This python version is not supported by depthai. Enter path to python binary version et least 3.8, or leave empty and python 3.10 will be installed automatically." - echo "Press ENTER key to continue" - read -e python_binary_path < /dev/tty - # python version is too low and user wants to install python 3.10 - if [ "$python_binary_path" = "" ]; then - install_python="true" - python_chosen="true" - fi - fi - fi - # User entered some path that should lead to python binary, save python --version output and the rest is dealt in the while loop logic. - if [ "$python_binary_path" != "" ]; then - python_executable="$python_binary_path" - python_version=$($python_binary_path --version) - if [[ "$python_version" != 'Python'* ]]; then - python_version="" - fi - fi -done +echo "Installing viewer dependencies..." - -write_in_file () { - # just make sure only strings are appended which are not in there yet - # first arg is text to write, second arg is the file path - if ! grep -Fxq "$1" "$2" - then - echo "$1" >> "$2" - fi -} - -COMMENT='# Entry point for Depthai demo app, enables to run in terminal' -BASHRC="$HOME/.bashrc" -ZSHRC="$HOME/.zshrc" -ADD_ENTRYPOINT_TO_PATH='export PATH=$PATH'":$ENTRYPOINT_DIR" - -# add to .bashrc only if it is not in there already -write_in_file "$COMMENT" "$BASHRC" -write_in_file "$ADD_ENTRYPOINT_TO_PATH" "$BASHRC" - -if [ -f "$ZSHRC" ]; then - write_in_file "$COMMENT" "$ZSHRC" - write_in_file "$ADD_ENTRYPOINT_TO_PATH" "$ZSHRC" -fi +readonly linux_pkgs=( + python3 + python3-pip + python3-venv + python3-dev + udev + cmake + git + python3-numpy +) if [[ $(uname -s) == "Darwin" ]]; then echo _____________________________ @@ -187,61 +85,48 @@ elif [[ $(uname -s) == "Linux" ]]; then echo "Updating sudo-apt." sudo apt-get update - - echo "Installing global dependencies." - sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bash - echo -e '\nRunning Linux installer.' - # clone depthai form git - if [ -d "$DEPTHAI_DIR" ]; then - echo "Demo app already downloaded. Checking out main and updating." - - else - echo "Downloading demo app." - git clone https://github.com/luxonis/depthai.git "$DEPTHAI_DIR" - fi - cd "$DEPTHAI_DIR" - git fetch - git checkout main - git pull + echo "Installing global dependencies." + sudo apt-get install -y "${linux_pkgs[@]}" - # install python 3.10 - if [ "$install_python" == "true" ]; then - echo "installing python 3.10" + echo "Creating python virtual environment in $VENV_DIR" - sudo yes "" | sudo add-apt-repository ppa:deadsnakes/ppa - sudo apt -y install python3.10 - sudo apt -y install python3.10-venv - python_executable=$(which python3.10) - fi - echo "Creating python virtual environment in $VENV_DIR" +if [ ! -d "$VENV_PATH" ]; then + echo "Creating virtual environment at $VENV_PATH" + mkdir -p "$VENV_PATH" + python3 -m venv "$VENV_PATH" +fi - machine=$(uname -m) - if [[ $machine != 'armv6l' && $machine != 'armv7l' && $machine != 'aarch64' && $machine != 'arm64' ]]; then - "$python_executable" -m venv "$VENV_DIR" - else - "$python_executable" -m venv "$VENV_DIR" --system-site-packages - fi + echo "Installing viewer in virtual environment..." + "$VENV_PATH/bin/python" -m pip install --upgrade pip + "$VENV_PATH/bin/python" -m pip install depthai-viewer packaging - source "$VENV_DIR/bin/activate" - python -m pip install --upgrade pip + echo "Creating udev rules..." + echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules + sudo udevadm control --reload-rules && sudo udevadm trigger - pip install packaging + echo -e '#!/bin/bash\nsource /opt/depthai_venv/bin/activate\nexec depthai-viewer "$@"' | sudo tee /usr/local/bin/depthai-viewer > /dev/null + sudo chmod +x /usr/local/bin/depthai-viewer - if [[ $machine != 'armv6l' && $machine != 'armv7l' && $machine != 'aarch64' && $machine != 'arm64' ]]; then - pip install pyqt5 - fi else echo "Error: Host $(uname -s) not supported." exit 99 fi +echo "Creating virtual environment at $VENV_PATH" + +if [ ! -d "$VENV_PATH" ]; then + echo "Creating virtual environment at $VENV_PATH" + mkdir -p "$VENV_PATH" + python3 -m venv "$VENV_PATH" +fi + + + +echo "Installation complete successfully" echo -e '\n\n:::::::::::::::: INSTALATION COMPLETE ::::::::::::::::\n' -echo -e '\nTo run demo app write in terminal.' -echo "Press ENTER KEY to finish and run the demo app..." -read -n1 key < /dev/tty -echo "STARTING DEMO APP." -python "$DEPTHAI_DIR/launcher/launcher.py" -r "$DEPTHAI_DIR" +echo -e '\nTo run demo app write **depthai-viewer** in terminal.' +depthai-viewer diff --git a/docs/requirements_mkdoc.txt b/docs/requirements_mkdoc.txt deleted file mode 100644 index e2ff4511a..000000000 --- a/docs/requirements_mkdoc.txt +++ /dev/null @@ -1,2 +0,0 @@ -git+https://github.com/luxonis/pybind11_mkdoc.git@da6c64251a0ebbc3ffc007477a0b9c9f20cac165 -libclang==16.0.6 diff --git a/docs/ubuntu:jammy/Containerfile b/docs/ubuntu:jammy/Containerfile new file mode 100644 index 000000000..3562a842f --- /dev/null +++ b/docs/ubuntu:jammy/Containerfile @@ -0,0 +1,15 @@ +FROM ubuntu:jammy + +WORKDIR /home/tester + +# Copy script into the container +COPY ../install_depthai.sh /home/tester/install_depthai.sh + +# Make script executable +RUN chmod +x /home/tester/install_depthai.sh + +# Install dependencies (modify if needed based on script requirements) +RUN apt update && apt install -y bash sudo + +# Run the script when the container starts +CMD ["/home/tester/install_depthai.sh"] diff --git a/docs/ubuntu:latest/Containerfile b/docs/ubuntu:latest/Containerfile new file mode 100644 index 000000000..ed00a2964 --- /dev/null +++ b/docs/ubuntu:latest/Containerfile @@ -0,0 +1,15 @@ +FROM ubuntu:latest + +WORKDIR /home/tester + +# Copy script into the container +COPY ../install_depthai.sh /home/tester/install_depthai.sh + +# Make script executable +RUN chmod +x /home/tester/install_depthai.sh + +# Install dependencies (modify if needed based on script requirements) +RUN apt update && apt install -y bash sudo + +# Run the script when the container starts +CMD ["/home/tester/install_depthai.sh"] From ea759133e52c8f26e05e011bb96ece3de7bb1b3c Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:10:34 +0100 Subject: [PATCH 02/17] fix: path in ci --- docs/debian:bookworm/Containerfile | 2 +- docs/ubuntu:jammy/Containerfile | 2 +- docs/ubuntu:latest/Containerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/debian:bookworm/Containerfile b/docs/debian:bookworm/Containerfile index f086f04d2..412808639 100644 --- a/docs/debian:bookworm/Containerfile +++ b/docs/debian:bookworm/Containerfile @@ -3,7 +3,7 @@ FROM debian:bookworm WORKDIR /home/tester # Copy script into the container -COPY ../install_depthai.sh /home/tester/install_depthai.sh +COPY docs/install_depthai.sh /home/tester/install_depthai.sh # Make script executable RUN chmod +x /home/tester/install_depthai.sh diff --git a/docs/ubuntu:jammy/Containerfile b/docs/ubuntu:jammy/Containerfile index 3562a842f..9c6013e10 100644 --- a/docs/ubuntu:jammy/Containerfile +++ b/docs/ubuntu:jammy/Containerfile @@ -3,7 +3,7 @@ FROM ubuntu:jammy WORKDIR /home/tester # Copy script into the container -COPY ../install_depthai.sh /home/tester/install_depthai.sh +COPY docs/install_depthai.sh /home/tester/install_depthai.sh # Make script executable RUN chmod +x /home/tester/install_depthai.sh diff --git a/docs/ubuntu:latest/Containerfile b/docs/ubuntu:latest/Containerfile index ed00a2964..a36e306eb 100644 --- a/docs/ubuntu:latest/Containerfile +++ b/docs/ubuntu:latest/Containerfile @@ -3,7 +3,7 @@ FROM ubuntu:latest WORKDIR /home/tester # Copy script into the container -COPY ../install_depthai.sh /home/tester/install_depthai.sh +COPY docs/install_depthai.sh /home/tester/install_depthai.sh # Make script executable RUN chmod +x /home/tester/install_depthai.sh From 20812231b0062392795af322840a09f54b5b3f67 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:13:36 +0100 Subject: [PATCH 03/17] fix: path in ci --- docs/debian:bookworm/Containerfile | 6 +----- docs/ubuntu:jammy/Containerfile | 6 +----- docs/ubuntu:latest/Containerfile | 6 +----- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/docs/debian:bookworm/Containerfile b/docs/debian:bookworm/Containerfile index 412808639..ed8cc6783 100644 --- a/docs/debian:bookworm/Containerfile +++ b/docs/debian:bookworm/Containerfile @@ -2,14 +2,10 @@ FROM debian:bookworm WORKDIR /home/tester -# Copy script into the container -COPY docs/install_depthai.sh /home/tester/install_depthai.sh +COPY /docs/install_depthai.sh /home/tester/install_depthai.sh -# Make script executable RUN chmod +x /home/tester/install_depthai.sh -# Install dependencies (modify if needed based on script requirements) RUN apt update && apt install -y bash sudo -# Run the script when the container starts CMD ["/home/tester/install_depthai.sh"] diff --git a/docs/ubuntu:jammy/Containerfile b/docs/ubuntu:jammy/Containerfile index 9c6013e10..3679bb9a7 100644 --- a/docs/ubuntu:jammy/Containerfile +++ b/docs/ubuntu:jammy/Containerfile @@ -2,14 +2,10 @@ FROM ubuntu:jammy WORKDIR /home/tester -# Copy script into the container -COPY docs/install_depthai.sh /home/tester/install_depthai.sh +COPY /docs/install_depthai.sh /home/tester/install_depthai.sh -# Make script executable RUN chmod +x /home/tester/install_depthai.sh -# Install dependencies (modify if needed based on script requirements) RUN apt update && apt install -y bash sudo -# Run the script when the container starts CMD ["/home/tester/install_depthai.sh"] diff --git a/docs/ubuntu:latest/Containerfile b/docs/ubuntu:latest/Containerfile index a36e306eb..fd101522d 100644 --- a/docs/ubuntu:latest/Containerfile +++ b/docs/ubuntu:latest/Containerfile @@ -2,14 +2,10 @@ FROM ubuntu:latest WORKDIR /home/tester -# Copy script into the container -COPY docs/install_depthai.sh /home/tester/install_depthai.sh +COPY /docs/install_depthai.sh /home/tester/install_depthai.sh -# Make script executable RUN chmod +x /home/tester/install_depthai.sh -# Install dependencies (modify if needed based on script requirements) RUN apt update && apt install -y bash sudo -# Run the script when the container starts CMD ["/home/tester/install_depthai.sh"] From c85dcea724ea264b854ba9a183da82e64d2f232b Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:15:54 +0100 Subject: [PATCH 04/17] fix: path in ci --- docs/debian:bookworm/Containerfile | 2 +- docs/ubuntu:jammy/Containerfile | 3 ++- docs/ubuntu:latest/Containerfile | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/debian:bookworm/Containerfile b/docs/debian:bookworm/Containerfile index ed8cc6783..d9cd60e78 100644 --- a/docs/debian:bookworm/Containerfile +++ b/docs/debian:bookworm/Containerfile @@ -2,7 +2,7 @@ FROM debian:bookworm WORKDIR /home/tester -COPY /docs/install_depthai.sh /home/tester/install_depthai.sh +COPY ../install_depthai.sh /home/tester/install_depthai.sh RUN chmod +x /home/tester/install_depthai.sh diff --git a/docs/ubuntu:jammy/Containerfile b/docs/ubuntu:jammy/Containerfile index 3679bb9a7..d1d8375c2 100644 --- a/docs/ubuntu:jammy/Containerfile +++ b/docs/ubuntu:jammy/Containerfile @@ -2,7 +2,8 @@ FROM ubuntu:jammy WORKDIR /home/tester -COPY /docs/install_depthai.sh /home/tester/install_depthai.sh + +COPY ../install_depthai.sh /home/tester/install_depthai.sh RUN chmod +x /home/tester/install_depthai.sh diff --git a/docs/ubuntu:latest/Containerfile b/docs/ubuntu:latest/Containerfile index fd101522d..28de1861a 100644 --- a/docs/ubuntu:latest/Containerfile +++ b/docs/ubuntu:latest/Containerfile @@ -2,7 +2,7 @@ FROM ubuntu:latest WORKDIR /home/tester -COPY /docs/install_depthai.sh /home/tester/install_depthai.sh +COPY ../install_depthai.sh /home/tester/install_depthai.sh RUN chmod +x /home/tester/install_depthai.sh From 2f1af7557631b4e27110155e5fcc7fdc713d7eac Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:22:08 +0100 Subject: [PATCH 05/17] fix: ajust pipline context --- .github/workflows/build-and-test-containers.yml | 2 +- docs/debian:bookworm/Containerfile | 2 +- docs/ubuntu:jammy/Containerfile | 2 +- docs/ubuntu:latest/Containerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test-containers.yml b/.github/workflows/build-and-test-containers.yml index 7af9afaee..5a3346f1e 100644 --- a/.github/workflows/build-and-test-containers.yml +++ b/.github/workflows/build-and-test-containers.yml @@ -25,7 +25,7 @@ jobs: - name: Build container run: | cd ${{ matrix.container }} - docker build -t test-${{ matrix.container }} -f Containerfile . + docker build -t test-${{ matrix.container }} -f Containerfile ../ - name: Run container run: | diff --git a/docs/debian:bookworm/Containerfile b/docs/debian:bookworm/Containerfile index d9cd60e78..5d5f931f0 100644 --- a/docs/debian:bookworm/Containerfile +++ b/docs/debian:bookworm/Containerfile @@ -2,7 +2,7 @@ FROM debian:bookworm WORKDIR /home/tester -COPY ../install_depthai.sh /home/tester/install_depthai.sh +COPY install_depthai.sh /home/tester/install_depthai.sh RUN chmod +x /home/tester/install_depthai.sh diff --git a/docs/ubuntu:jammy/Containerfile b/docs/ubuntu:jammy/Containerfile index d1d8375c2..e07539783 100644 --- a/docs/ubuntu:jammy/Containerfile +++ b/docs/ubuntu:jammy/Containerfile @@ -3,7 +3,7 @@ FROM ubuntu:jammy WORKDIR /home/tester -COPY ../install_depthai.sh /home/tester/install_depthai.sh +COPY install_depthai.sh /home/tester/install_depthai.sh RUN chmod +x /home/tester/install_depthai.sh diff --git a/docs/ubuntu:latest/Containerfile b/docs/ubuntu:latest/Containerfile index 28de1861a..23e3a0e06 100644 --- a/docs/ubuntu:latest/Containerfile +++ b/docs/ubuntu:latest/Containerfile @@ -2,7 +2,7 @@ FROM ubuntu:latest WORKDIR /home/tester -COPY ../install_depthai.sh /home/tester/install_depthai.sh +COPY install_depthai.sh /home/tester/install_depthai.sh RUN chmod +x /home/tester/install_depthai.sh From 91a2dca82c021f3f6173d601cf9d2932639f7bb3 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:28:53 +0100 Subject: [PATCH 06/17] fix: build issues --- docs/install_depthai.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index da1c6dc30..9c194beb9 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -91,7 +91,7 @@ elif [[ $(uname -s) == "Linux" ]]; then echo "Installing global dependencies." sudo apt-get install -y "${linux_pkgs[@]}" - echo "Creating python virtual environment in $VENV_DIR" + echo "Creating python virtual environment in $VENV_PATH" if [ ! -d "$VENV_PATH" ]; then @@ -108,7 +108,7 @@ fi echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules sudo udevadm control --reload-rules && sudo udevadm trigger - echo -e '#!/bin/bash\nsource /opt/depthai_venv/bin/activate\nexec depthai-viewer "$@"' | sudo tee /usr/local/bin/depthai-viewer > /dev/null + echo -e '#!/bin/bash\nsource .local/share/virtualenvs\nexec depthai-viewer "$@"' | sudo tee /usr/local/bin/depthai-viewer > /dev/null sudo chmod +x /usr/local/bin/depthai-viewer else From 125df35f48810e0f9d2b808ffa9aa45624270f62 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Mon, 3 Feb 2025 15:33:29 +0100 Subject: [PATCH 07/17] fix: dont open after install --- docs/install_depthai.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index 9c194beb9..fc63dcce5 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -129,4 +129,3 @@ fi echo "Installation complete successfully" echo -e '\n\n:::::::::::::::: INSTALATION COMPLETE ::::::::::::::::\n' echo -e '\nTo run demo app write **depthai-viewer** in terminal.' -depthai-viewer From 58a06b65f9cf77126300df044215e1e21a65940e Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 4 Feb 2025 12:14:58 +0100 Subject: [PATCH 08/17] fix: disable bash version check --- docs/install_dependencies.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/install_dependencies.sh b/docs/install_dependencies.sh index 762950ffd..d635153b8 100755 --- a/docs/install_dependencies.sh +++ b/docs/install_dependencies.sh @@ -117,12 +117,6 @@ readonly fedora_pkgs=( # libsm6 libxext6 libgl1-mesa-glx ) -# Check Bash version -if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then - echo "This script requires Bash 4.0 or higher. You are using Bash ${BASH_VERSION}. Please upgrade your Bash version." - exit 1 -fi - print_action () { green="\e[0;32m" reset="\e[0;0m" From e1d9dde717f097581a4215de8c1b536462f22982 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 4 Feb 2025 12:22:40 +0100 Subject: [PATCH 09/17] feat: update mac address --- docs/install_depthai.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index fc63dcce5..816df43fa 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -23,7 +23,7 @@ if [[ $(uname -s) == "Darwin" ]]; then echo "Running macOS installer." echo "Installing global dependencies." - bash -c "$(curl -fL https://docs.luxonis.com/install_dependencies.sh)" + bash -c "$(curl -fL https://raw.githubusercontent.com/luxonis/depthai-python/refs/heads/feat/install-rework/docs/install_dependencies.sh)" echo "Upgrading brew." brew update From 8a6b2ede57ce19e1d9133f7ac1922bc772d333b3 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 4 Feb 2025 12:59:50 +0100 Subject: [PATCH 10/17] chore: improve mac script --- docs/install_dependencies.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/install_dependencies.sh b/docs/install_dependencies.sh index d635153b8..1d2a2b3ba 100755 --- a/docs/install_dependencies.sh +++ b/docs/install_dependencies.sh @@ -131,7 +131,12 @@ version_lte() { [[ "$1" == "$(echo -e "$1\n$2" | sort -V | head -n1)" ]] } -declare -A debian_versions=( + + +# Function to lookup and print Debian version number +lookup_debian_version_number() { + + declare -A debian_versions=( ["trixie/sid"]="13" ["bookworm/sid"]="12" ["bullseye/sid"]="11" @@ -141,10 +146,7 @@ declare -A debian_versions=( ["wheezy/sid"]="7" ["squeeze/sid"]="6" ) - -# Function to lookup and print Debian version number -lookup_debian_version_number() { - debian_version_string="$1" +debian_version_string="$1" version_number="${debian_versions[$debian_version_string]}" if [ -n "$version_number" ]; then From c8e452f70701193d2a25a2be69408ed567f04a25 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 4 Feb 2025 18:16:51 +0100 Subject: [PATCH 11/17] fix: mac scipt --- docs/install_depthai.sh | 120 +++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 68 deletions(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index 816df43fa..5c78ebcb9 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -VENV_PATH=".local/share/virtualenvs" +VENV_PATH="$HOME/.local/share/virtualenvs" echo "Installing viewer dependencies..." @@ -15,11 +15,34 @@ readonly linux_pkgs=( git python3-numpy ) +PYTHONPATH=$(which python3) +# Function to create virtual environment +create_venv() { + echo "Creating python virtual environment in $VENV_PATH" + + if [ ! -d "$VENV_PATH" ]; then + echo "Creating virtual environment at $VENV_PATH" + mkdir -p "$VENV_PATH" + "$PYTHONPATH" -m venv "$VENV_PATH" + fi +} + +# Function to install depthai viewer +install_depthai() { + echo "Installing viewer in virtual environment..." + "$VENV_PATH/bin/python" -m pip install --upgrade pip + "$VENV_PATH/bin/python" -m pip install depthai-viewer packaging depthai + + sudo mkdir -p /usr/local/bin/ + printf '#!/bin/bash\nsource %s/bin/activate\n depthai-viewer "$@"' $VENV_PATH | sudo tee /usr/local/bin/depthai-viewer > /dev/null + sudo chmod +x /usr/local/bin/depthai-viewer +} +# macOS specific installation if [[ $(uname -s) == "Darwin" ]]; then - echo _____________________________ + echo "_____________________________" echo "Calling macOS_installer.sh" - echo _____________________________ + echo "_____________________________" echo "Running macOS installer." echo "Installing global dependencies." @@ -27,27 +50,13 @@ if [[ $(uname -s) == "Darwin" ]]; then echo "Upgrading brew." brew update + brew install cmake - # clone depthai form git - if [ -d "$DEPTHAI_DIR" ]; then - echo "Demo app already downloaded. Checking out main and updating." - else - echo "Downloading demo app." - git clone https://github.com/luxonis/depthai.git "$DEPTHAI_DIR" - fi - cd "$DEPTHAI_DIR" - git fetch - git checkout main - git pull - - # install python 3.10 and python dependencies - brew update - - if [ "$install_python" == "true" ]; then - echo "installing python 3.10" - brew install python@3.10 - python_executable=$(which python3.10) - fi + # Install Python 3.10 and dependencies if requested + echo "Installing Python 3.10" + brew install python@3.10 + + PYTHONPATH=$(which python3.10) # pip does not have pyqt5 for arm if [[ $(uname -m) == 'arm64' ]]; then @@ -55,77 +64,52 @@ if [[ $(uname -s) == "Darwin" ]]; then brew install pyqt@5 fi - # create python virtual environment - echo "Creating python virtual environment in $VENV_DIR" - echo "$python_executable" - "$python_executable" -m venv "$VENV_DIR" - # activate environment - source "$VENV_DIR/bin/activate" - python -m pip install --upgrade pip + create_venv + + - # install launcher dependencies - # only on mac silicon point PYTHONPATH to pyqt5 installation via homebrew, otherwise install pyqt5 with pip + "$VENV_PATH/bin/python" -m pip install --upgrade pip setuptools wheel + # If on ARM, set the PYTHONPATH to include the Homebrew installation path if [[ $(uname -m) == 'arm64' ]]; then if [[ ":$PYTHONPATH:" == *":/opt/homebrew/lib/python3.10/site-packages:"* ]]; then - echo "/opt/homebrew/lib/python$nr_1.$nr_2/site-packages already in PYTHONPATH" + echo "/opt/homebrew/lib/python3.10/site-packages already in PYTHONPATH" else - export "PYTHONPATH=/opt/homebrew/lib/python$nr_1.$nr_2/site-packages:"$PYTHONPATH - echo "/opt/homebrew/lib/pythonv$nr_1.$nr_2/site-packages added to PYTHONPATH" + export "PYTHONPATH=/opt/homebrew/lib/python3.10/site-packages:"$PYTHONPATH + echo "/opt/homebrew/lib/python3.10/site-packages added to PYTHONPATH" fi else - pip install pyqt5 + "$VENV_PATH/bin/python" -m pip install pyqt5 fi - pip install packaging + install_depthai +# Linux specific installation elif [[ $(uname -s) == "Linux" ]]; then - echo _____________________________ + echo "_____________________________" echo "Calling linux_installer.sh" - echo _____________________________ + echo "_____________________________" echo "Updating sudo-apt." sudo apt-get update - echo -e '\nRunning Linux installer.' - + echo "Running Linux installer." echo "Installing global dependencies." sudo apt-get install -y "${linux_pkgs[@]}" - echo "Creating python virtual environment in $VENV_PATH" - - -if [ ! -d "$VENV_PATH" ]; then - echo "Creating virtual environment at $VENV_PATH" - mkdir -p "$VENV_PATH" - python3 -m venv "$VENV_PATH" -fi - - echo "Installing viewer in virtual environment..." - "$VENV_PATH/bin/python" -m pip install --upgrade pip - "$VENV_PATH/bin/python" -m pip install depthai-viewer packaging - + create_venv echo "Creating udev rules..." echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules sudo udevadm control --reload-rules && sudo udevadm trigger - echo -e '#!/bin/bash\nsource .local/share/virtualenvs\nexec depthai-viewer "$@"' | sudo tee /usr/local/bin/depthai-viewer > /dev/null - sudo chmod +x /usr/local/bin/depthai-viewer + install_depthai +# Catch all other unsupported OS else echo "Error: Host $(uname -s) not supported." exit 99 fi -echo "Creating virtual environment at $VENV_PATH" - -if [ ! -d "$VENV_PATH" ]; then - echo "Creating virtual environment at $VENV_PATH" - mkdir -p "$VENV_PATH" - python3 -m venv "$VENV_PATH" -fi - - - +# Final success message echo "Installation complete successfully" -echo -e '\n\n:::::::::::::::: INSTALATION COMPLETE ::::::::::::::::\n' -echo -e '\nTo run demo app write **depthai-viewer** in terminal.' +echo -e '\n\n:::::::::::::::: INSTALLATION COMPLETE ::::::::::::::::\n' +echo -e '\nTo run demo app, write **depthai-viewer** in terminal.' From 000916137bf2ab09f2f571c2e8de97b8bd413a33 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 5 Feb 2025 16:26:51 +0100 Subject: [PATCH 12/17] fix: add numpy on mac --- docs/install_dependencies.sh | 1 + docs/install_depthai.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/install_dependencies.sh b/docs/install_dependencies.sh index 1d2a2b3ba..5ec5036e9 100755 --- a/docs/install_dependencies.sh +++ b/docs/install_dependencies.sh @@ -28,6 +28,7 @@ readonly debian_pkgs=( libtiff-dev # https://stackoverflow.com/questions/55313610 ffmpeg + python3-venv libsm6 libxext6 python3-pyqt5 diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index 5c78ebcb9..5305f30b7 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -68,7 +68,7 @@ if [[ $(uname -s) == "Darwin" ]]; then - "$VENV_PATH/bin/python" -m pip install --upgrade pip setuptools wheel + "$VENV_PATH/bin/python" -m pip install --upgrade pip setuptools wheel numpy # If on ARM, set the PYTHONPATH to include the Homebrew installation path if [[ $(uname -m) == 'arm64' ]]; then if [[ ":$PYTHONPATH:" == *":/opt/homebrew/lib/python3.10/site-packages:"* ]]; then From bf802889e1481c5213faa97d237e507d1fa046b0 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 5 Feb 2025 16:42:07 +0100 Subject: [PATCH 13/17] feat: rework worker --- .../workflows/build-and-test-containers.yml | 30 +++++++++---------- .../workflows/test-install-dependencies.yml | 2 ++ docs/debian:bookworm/Containerfile | 11 ------- docs/ubuntu:jammy/Containerfile | 12 -------- docs/ubuntu:latest/Containerfile | 11 ------- 5 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 docs/debian:bookworm/Containerfile delete mode 100644 docs/ubuntu:jammy/Containerfile delete mode 100644 docs/ubuntu:latest/Containerfile diff --git a/.github/workflows/build-and-test-containers.yml b/.github/workflows/build-and-test-containers.yml index 5a3346f1e..5a99d108c 100644 --- a/.github/workflows/build-and-test-containers.yml +++ b/.github/workflows/build-and-test-containers.yml @@ -1,4 +1,4 @@ -name: Build and Test viewer on Linux +name: Build and Test viewer on Linux and macOS on: push: @@ -10,26 +10,26 @@ on: jobs: build-and-test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: - container: - - docs/debian:bookworm - - docs/ubuntu:jammy - - docs/ubuntu:latest + os: + - ubuntu-latest + - ubuntu-24.04 + - ubuntu-22.04 + - macos-latest + - macos-14 + - macos-13 steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Build container - run: | - cd ${{ matrix.container }} - docker build -t test-${{ matrix.container }} -f Containerfile ../ + - name: Set execute permissions for install script + run: chmod +x install_depthai.sh - - name: Run container - run: | - docker run --rm test-${{ matrix.container }} + - name: Run installation script + run: ./install_depthai.sh - - name: Check exit status - run: echo "Container ${{ matrix.container }} exited successfully" + - name: Verify installation success + run: echo "Installation script executed successfully" diff --git a/.github/workflows/test-install-dependencies.yml b/.github/workflows/test-install-dependencies.yml index 5635a594b..a84c98770 100644 --- a/.github/workflows/test-install-dependencies.yml +++ b/.github/workflows/test-install-dependencies.yml @@ -6,10 +6,12 @@ paths: - 'docs/install_dependencies.sh' - 'examples/install_requirements.py' + - 'docs/install_depthai.sh' pull_request: paths: - 'docs/install_dependencies.sh' - 'examples/install_requirements.py' + - 'docs/install_depthai.sh' jobs: test_linux: diff --git a/docs/debian:bookworm/Containerfile b/docs/debian:bookworm/Containerfile deleted file mode 100644 index 5d5f931f0..000000000 --- a/docs/debian:bookworm/Containerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM debian:bookworm - -WORKDIR /home/tester - -COPY install_depthai.sh /home/tester/install_depthai.sh - -RUN chmod +x /home/tester/install_depthai.sh - -RUN apt update && apt install -y bash sudo - -CMD ["/home/tester/install_depthai.sh"] diff --git a/docs/ubuntu:jammy/Containerfile b/docs/ubuntu:jammy/Containerfile deleted file mode 100644 index e07539783..000000000 --- a/docs/ubuntu:jammy/Containerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM ubuntu:jammy - -WORKDIR /home/tester - - -COPY install_depthai.sh /home/tester/install_depthai.sh - -RUN chmod +x /home/tester/install_depthai.sh - -RUN apt update && apt install -y bash sudo - -CMD ["/home/tester/install_depthai.sh"] diff --git a/docs/ubuntu:latest/Containerfile b/docs/ubuntu:latest/Containerfile deleted file mode 100644 index 23e3a0e06..000000000 --- a/docs/ubuntu:latest/Containerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:latest - -WORKDIR /home/tester - -COPY install_depthai.sh /home/tester/install_depthai.sh - -RUN chmod +x /home/tester/install_depthai.sh - -RUN apt update && apt install -y bash sudo - -CMD ["/home/tester/install_depthai.sh"] From 2cea12791bc9cc98376b9d8c57f82f19a5e6d5b5 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 5 Feb 2025 16:46:21 +0100 Subject: [PATCH 14/17] fix: path in runner --- .github/workflows/build-and-test-containers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-containers.yml b/.github/workflows/build-and-test-containers.yml index 5a99d108c..b7d0a2131 100644 --- a/.github/workflows/build-and-test-containers.yml +++ b/.github/workflows/build-and-test-containers.yml @@ -26,10 +26,10 @@ jobs: uses: actions/checkout@v4 - name: Set execute permissions for install script - run: chmod +x install_depthai.sh + run: chmod +x docs/install_depthai.sh - name: Run installation script - run: ./install_depthai.sh + run: ./docs/install_depthai.sh - name: Verify installation success run: echo "Installation script executed successfully" From fe692342cd7e389b98dfe6f2d01f6cc0c2987094 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Sun, 9 Feb 2025 12:30:33 +0000 Subject: [PATCH 15/17] fix: chore change venv path --- docs/install_depthai.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index 5305f30b7..2513b069a 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -VENV_PATH="$HOME/.local/share/virtualenvs" +VENV_PATH="$HOME/.local/share/virtualenvs/depthai-viewer" echo "Installing viewer dependencies..." @@ -18,12 +18,12 @@ readonly linux_pkgs=( PYTHONPATH=$(which python3) # Function to create virtual environment create_venv() { - echo "Creating python virtual environment in $VENV_PATH" - if [ ! -d "$VENV_PATH" ]; then echo "Creating virtual environment at $VENV_PATH" mkdir -p "$VENV_PATH" "$PYTHONPATH" -m venv "$VENV_PATH" + else + echo "Virtual environment already exists at $VENV_PATH" fi } From 32cd428775448f57c775b7b760e649a094c21d73 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Fri, 14 Feb 2025 10:39:51 +0100 Subject: [PATCH 16/17] fix: hide run message when no display --- docs/install_depthai.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index 2513b069a..33cf5bed4 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -112,4 +112,8 @@ fi # Final success message echo "Installation complete successfully" echo -e '\n\n:::::::::::::::: INSTALLATION COMPLETE ::::::::::::::::\n' -echo -e '\nTo run demo app, write **depthai-viewer** in terminal.' +if [[ $(uname -s) == "Darwin" ]]; then + echo -e '\nTo run demo app, write **depthai-viewer** in terminal.' +elif [[ $DISPLAY != "" ]]; then + echo -e '\nTo run demo app, write **depthai-viewer** in terminal or run **depthai-viewer** from the terminal.' +fi From daf4a37e75c9955ba92f2a406c8ba8c0122b3921 Mon Sep 17 00:00:00 2001 From: IhtDzenda Date: Fri, 14 Feb 2025 11:14:48 +0100 Subject: [PATCH 17/17] fix: succes message --- docs/install_depthai.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh index 33cf5bed4..d530b959c 100755 --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -115,5 +115,5 @@ echo -e '\n\n:::::::::::::::: INSTALLATION COMPLETE ::::::::::::::::\n' if [[ $(uname -s) == "Darwin" ]]; then echo -e '\nTo run demo app, write **depthai-viewer** in terminal.' elif [[ $DISPLAY != "" ]]; then - echo -e '\nTo run demo app, write **depthai-viewer** in terminal or run **depthai-viewer** from the terminal.' + echo -e '\nTo run demo app, write **depthai-viewer** in terminal.' fi