#!/bin/sh

set -e

PREFIX=$HOME/.local

if [ "$(uname -s)" != "Darwin" ]; then
    if [ ! -e "$PREFIX/bin/ffmpeg" ]; then
        curl http://www.ffmpeg.org/releases/ffmpeg-4.1.3.tar.xz | tar xJ
        cd ffmpeg-4.1.3
        ./configure --prefix=$PREFIX \
            --disable-static --enable-shared \
            --enable-gpl \
            --enable-libmp3lame \
            --enable-libx264
        make
        make install
        cd ..
    fi
    export LD_LIBRARY_PATH=$PREFIX/lib
    export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
fi

pip3 install -U pip setuptools

# force cryptography to use the system's OpenSSL if requested
if [ -n "$CRYPTOGRAPHY_NO_BINARY" ]; then
    pip3 install cryptography --no-binary cryptography
fi

pip3 install aiohttp coverage opencv-python websockets
