#!/bin/bash
# See: http://mybinder.readthedocs.io/en/latest/using.html#postbuild
python setup.py develop --user

# repo2docker does not use a conda environment, hence $CONDA_PREFIX is not
# set by default. Until there is a standard way of setting compiler variables
# we add the hardcoded conda-root path to the relevant environment variables:
cat <<EOF >>/srv/conda/lib/python3.6/site-packages/usercustomize.py
import os
ld_lib_pth = os.environ.get('LD_LIBRARY_PATH', '')
lib_pth = os.environ.get('LIBRARY_PATH', '')
cpp_inc_pth = os.environ.get('CPLUS_INCLUDE_PATH', '')
os.environ['LD_LIBRARY_PATH'] = '/srv/conda/lib' + ((':%s' % ld_lib_pth) if ld_lib_pth else '') 
os.environ['LIBRARY_PATH'] = '/srv/conda/lib' + ((':%s' % lib_pth) if lib_pth else '')
os.environ['CPLUS_INCLUDE_PATH'] = '/srv/conda/include' + ((':%s' % cpp_inc_pth) if cpp_inc_pth else '')
EOF
