#!/bin/bash
set -e

HOME=`pwd`/home
mkdir $HOME
export PIP_DOWNLOAD_CACHE=$HOME/../../pip_cache
cat ../openmedialibrary/requirements.txt \
    | grep -v lxml \
    | grep -v pyopenssl \
    | grep -v pyCrypto \
    | grep -v pillow \
    | grep -v simplejson \
    > requirements.txt
echo setuptools >> requirements.txt
echo six >> requirements.txt
pip3 install -r requirements.txt -I --user
mkdir old
mv lib bin old
mv home/.local/lib lib
test -e home/.local/bin && mv home/.local/bin bin

virtualenv -p /usr/bin/python3.5 p35
p35/bin/pip3 install ed25519
cp p35/lib/python3.5/site-packages/ed25519/_ed25519.cpython-35m-i686-linux-gnu.so lib/python3.4/site-packages/ed25519/_ed25519.cpython-35m-i686-linux-gnu.so

rm -r home old requirements.txt p35
