setup_bash.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. BINDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  2. TOPDIR=`dirname ${BINDIR}`
  3. checkPyModule()
  4. {
  5. PACKAGE=$1
  6. VERSION=$(python -c "$2" 2>/dev/null )
  7. if [ $? -ne 0 ]
  8. then
  9. printf "%12s (%b)\n" "${PACKAGE}" "\e[31mnot found\e[0m"
  10. else
  11. printf "%12s (%b)\n" "${PACKAGE}" "\e[32mfound ${VERSION}\e[0m"
  12. fi
  13. }
  14. if [ ".$QUIET" == "." ]
  15. then
  16. printf "\n"
  17. printf "\e[30m\e[107mIMPORTANT\e[0m: make sure you __source__ this script\n"
  18. printf "rather than execute it:\n"
  19. printf "\n"
  20. printf "\e[1m yourprompt$ . \$FD_PATH/setup_bash.sh\e[0m\n"
  21. printf "\n"
  22. printf "otherwise the paths will not be correctly set. If you'd like to\n"
  23. printf "silence this annoying message in the future, source the script\n"
  24. printf "like this:"
  25. printf "\n"
  26. printf "\e[1m yourprompt$ QUIET=1 . \$FD_PATH/setup_bash.sh\e[0m\n"
  27. printf "\n"
  28. printf "Python package dependency check:\n"
  29. for PACKAGE in numpy scipy numexpr matplotlib
  30. do
  31. checkPyModule $PACKAGE "import ${PACKAGE}; print ${PACKAGE}.__version__; exit()"
  32. done
  33. checkPyModule "ROOT" "import ROOT; print ROOT.gROOT.GetVersion(); exit()"
  34. printf "\n"
  35. printf "ROOT is __optional__, and is required only to import Tree objects from\n"
  36. printf " .root files. If ROOT is not installed, you can still import .csv\n"
  37. printf " files."
  38. printf "\n"
  39. fi
  40. [[ ":$PATH:" != *${BINDIR}* ]] && export PATH="${BINDIR}:${PATH}"
  41. [[ ":$PYTHONPATH:" != *${TOPDIR}* ]] && export PYTHONPATH="${TOPDIR}:${PYTHONPATH}"
  42. export FD_DIR=${TOPDIR}