diff --git a/.github/workflows/build-and-test-containers.yml b/.github/workflows/build-and-test-containers.yml new file mode 100644 index 000000000..b7d0a2131 --- /dev/null +++ b/.github/workflows/build-and-test-containers.yml @@ -0,0 +1,35 @@ +name: Build and Test viewer on Linux and macOS + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - ubuntu-24.04 + - ubuntu-22.04 + - macos-latest + - macos-14 + - macos-13 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set execute permissions for install script + run: chmod +x docs/install_depthai.sh + + - name: Run installation script + run: ./docs/install_depthai.sh + + - 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/install_dependencies.sh b/docs/install_dependencies.sh index 762950ffd..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 @@ -117,12 +118,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" @@ -137,7 +132,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" @@ -147,10 +147,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 diff --git a/docs/install_depthai.sh b/docs/install_depthai.sh old mode 100644 new mode 100755 index e36ee888a..d530b959c --- a/docs/install_depthai.sh +++ b/docs/install_depthai.sh @@ -1,155 +1,62 @@ #!/bin/bash - -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 - - if [ -d "$WORKING_DIR" ]; then - echo "Directory: $WORKING_DIR is OK" - path_correct="true" +set -e + +VENV_PATH="$HOME/.local/share/virtualenvs/depthai-viewer" + +echo "Installing viewer dependencies..." + +readonly linux_pkgs=( + python3 + python3-pip + python3-venv + python3-dev + udev + cmake + git + python3-numpy +) +PYTHONPATH=$(which python3) +# Function to create virtual environment +create_venv() { + if [ ! -d "$VENV_PATH" ]; then + echo "Creating virtual environment at $VENV_PATH" + mkdir -p "$VENV_PATH" + "$PYTHONPATH" -m venv "$VENV_PATH" 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 - - -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" + echo "Virtual environment already exists at $VENV_PATH" 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" +# 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 -if [ -f "$ZSHRC" ]; then - write_in_file "$COMMENT" "$ZSHRC" - write_in_file "$ADD_ENTRYPOINT_TO_PATH" "$ZSHRC" -fi + 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." - 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 + 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 @@ -157,91 +64,56 @@ 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 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 - 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 "Running Linux installer." echo "Installing global dependencies." - sudo wget -qO- https://docs.luxonis.com/install_dependencies.sh | bash + sudo apt-get install -y "${linux_pkgs[@]}" - echo -e '\nRunning Linux installer.' + 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 - # clone depthai form git - if [ -d "$DEPTHAI_DIR" ]; then - echo "Demo app already downloaded. Checking out main and updating." + install_depthai - 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 - if [ "$install_python" == "true" ]; then - echo "installing python 3.10" - - 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" - - 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 - - source "$VENV_DIR/bin/activate" - python -m pip install --upgrade pip - - pip install packaging - - if [[ $machine != 'armv6l' && $machine != 'armv7l' && $machine != 'aarch64' && $machine != 'arm64' ]]; then - pip install pyqt5 - fi +# Catch all other unsupported OS else echo "Error: Host $(uname -s) not supported." exit 99 fi -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" +# Final success message +echo "Installation complete successfully" +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.' +fi 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