#!/usr/bin/env bash

cd src

# Apply patches
for patch in ../patches/*.patch; do
    [ -r "$patch" ] || continue  # Skip non-existing or non-readable patches
    patch -p1 <"$patch"
    if [ $? -ne 0 ]; then
        echo >&2 "Error applying '$patch'"
        exit 1
    fi
done

# pip can install itself!
# need to use --upgrade or else pip, which is importing itself, will think
# itself is already installed
python -m pip install --verbose --no-index --upgrade .
