[buildout]

# A proper SR for Dream with no external dependecies (fortran, etc),
# but which uses a virtualenv to ease packaging on the python side.

extends = 
  ../../stack/slapos.cfg
  ../../component/git/buildout.cfg
  ../../component/gcc/buildout.cfg
  ../../component/libatlas/buildout.cfg
  ../../component/libblas/buildout.cfg
  ../../component/r-language/buildout.cfg

parts =
  python2.7-virtualenv
  eggs
  gcc-fortran
  libatlas
  libblas
  r-language
  sh-dream-environment
  scikit-env


[eggs]
recipe = zc.recipe.egg
eggs =
  ${lxml-python:egg}
  slapos.cookbook
  collective.recipe.template


[scikit-env]
recipe = cp.recipe.cmd
location = ${buildout:parts-directory}/${:_buildout_section_name_}
install_cmd =
  mkdir -p ${:location}
  cd ${:location}
  unset PYTHONPATH
  ${python2.7-virtualenv:executable} ${:location}
  . ${:location}/bin/activate
  export ATLAS=${libatlas:location}/lib/libsatlas.so
  export BLAS=${libblas:location}/lib/libfblas.a
  LD_PRELOAD=${gcc-fortran:location}/lib64/libgfortran.so.3
  #pip install -U setuptools
  #pip install -U pip
  pip install numpy
  pip install simpy==2.3
  pip install scipy
  pip install scikit-learn
  pip install xlrd
  pip install xlwt
  pip install flask
  pip install pyparsing==1.5.7
  pip install pydot
  # export LDFLAGS="-lncurses"
  export PATH=${r-language:location}/bin:$PATH
  # pip install rpy2
  # clone repo for:
  #   bug fix - https://bitbucket.org/lgautier/rpy2/issue/183
  # (may switch to released egg later)
  pip install mercurial
  hg clone -b version_2.4.x_noreadline https://marco.mariani@bitbucket.org/marco.mariani/rpy2
  cd rpy2
  python setup.py install
  cd ..
  ${git:location}/bin/git clone http://git.erp5.org/repos/dream.git -b marco
  cd dream
  python setup.py install
update_cmd = ${:install_cmd}



[sh-dream-environment]
# environment needed for running/debugging the applications, exported to a shell script to be sourced.
recipe = collective.recipe.template
output = ${buildout:directory}/environment.sh
input = inline:
  unset PYTHONPATH
  export PATH="${r-language:location}/bin:$PATH"
  export LD_LIBRARY_PATH="`${r-language:location}/bin/R RHOME`/lib:$LD_LIBRARY_PATH"
  export LD_PRELOAD=${gcc-fortran:location}/lib64/libgfortran.so.3


[versions]
cp.recipe.cmd = 0.5nxd001