2
0

sklearn 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. set -e
  3. root=$(cd $(dirname ${0})/..; pwd)
  4. third_party=${root}/third_party
  5. tools=${root}/tools
  6. identifier=scikit-learn
  7. virtualenv=${third_party}/virtualenv/${identifier}
  8. if [ $(which python3) ]; then
  9. python="python3"
  10. else
  11. python="python"
  12. fi
  13. bold() {
  14. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  15. }
  16. git_sync() {
  17. mkdir -p "${third_party}"
  18. if [ -d "${third_party}/${1}" ]; then
  19. git -C "${third_party}/${1}" fetch --quiet -p
  20. git -C "${third_party}/${1}" reset --quiet --hard origin/master
  21. else
  22. git -C "${third_party}" clone --quiet --recursive ${2} ${1}
  23. fi
  24. git -C "${third_party}" submodule update --quiet --init
  25. }
  26. sync() {
  27. bold "sklearn sync"
  28. git_sync numpy https://github.com/numpy/numpy.git
  29. git_sync scikit-learn https://github.com/scikit-learn/scikit-learn.git
  30. git_sync lightgbm https://github.com/Microsoft/LightGBM.git
  31. git_sync xgboost https://github.com/dmlc/xgboost.git
  32. }
  33. install() {
  34. bold "sklearn install"
  35. case "$(uname)" in
  36. "Darwin")
  37. brew list libomp > /dev/null 2>&1 || brew install libomp > /dev/null
  38. export CC=/usr/bin/clang
  39. export CXX=/usr/bin/clang++
  40. export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
  41. export CFLAGS="$CFLAGS -I/usr/local/opt/libomp/include"
  42. export CXXFLAGS="$CXXFLAGS -I/usr/local/opt/libomp/include"
  43. export LDFLAGS="$LDFLAGS -L/usr/local/opt/libomp/lib -lomp"
  44. export DYLD_LIBRARY_PATH=/usr/local/opt/libomp/lib
  45. ;;
  46. esac
  47. [ -n "$(python3 -m pip list --format columns --disable-pip-version-check | grep -w virtualenv)" ] || ${python} -m pip install --force-reinstall --user --quiet virtualenv
  48. [ -d "${virtualenv}" ] || virtualenv --quiet -p ${python} ${virtualenv}
  49. source ${virtualenv}/bin/activate
  50. ${python} -m pip install --quiet Cython
  51. ${python} -m pip install --quiet numpy
  52. ${python} -m pip install ${third_party}/scikit-learn
  53. deactivate
  54. }
  55. metadata() {
  56. bold "sklearn metadata"
  57. source ${virtualenv}/bin/activate
  58. pushd ${tools} > /dev/null
  59. ${python} sklearn-script.py
  60. popd > /dev/null
  61. deactivate
  62. }
  63. while [ "$#" != 0 ]; do
  64. command="$1" && shift
  65. case "${command}" in
  66. "sync") sync;;
  67. "install") install;;
  68. "metadata") metadata;;
  69. esac
  70. done