Skip to content

Instantly share code, notes, and snippets.

@snorfalorpagus
Created May 5, 2017 13:41
Show Gist options
  • Save snorfalorpagus/b6ab9f37b2c87696ee56066da4b3c760 to your computer and use it in GitHub Desktop.
Save snorfalorpagus/b6ab9f37b2c87696ee56066da4b3c760 to your computer and use it in GitHub Desktop.
EC2 helper script to install/upgrade Pywr master
#!/bin/bash
# quit immediately on error
set -e
# install miniconda
rm -rf /opt/miniconda3
mkdir -p /opt/miniconda3
ln -f -s /opt/miniconda3 ~/miniconda3
CONDA_SCRIPT="Miniconda3-latest-Linux-x86_64.sh"
wget https://repo.continuum.io/miniconda/${CONDA_SCRIPT} -O ${CONDA_SCRIPT}
bash ${CONDA_SCRIPT} -b -p /opt/miniconda3 -f
# activate root environment
source $HOME/miniconda3/bin/activate
# add channels
conda config --add channels conda-forge
conda config --add channels snorfalorpagus
# upgrade everything
conda upgrade --all --quiet --yes
conda install click pytables cython pytest networkx numpy scipy future glpk packaging pandas xlrd --quiet --yes
# build master
cd /shared/bootstrap/pywr
git reset --hard HEAD
git checkout master
git pull
rm -rf build dist
find . | grep -E "(__pycache__|\.pyc|\.pyo|\.pyd|\.so|\.c$)" | xargs rm -rf
python setup.py build_ext --with-glpk -I${CONDA_PREFIX}/include -L${CONDA_PREFIX}/lib install
py.test tests
# create tarball
conda clean --all --yes
cd /opt
chown -R ec2-user:ec2-user miniconda3
rm -rf /opt/miniconda3/pkgs/*
tar -cvjSf /shared/miniconda3_pywr.tar.bz2 miniconda3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment