2
0

sklearn 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. case "${OSTYPE}" in
  5. msys*) python="winpty python";;
  6. *) python=python3;;
  7. esac
  8. bold() {
  9. echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
  10. }
  11. venv() {
  12. venv_dir=./third_party/env/scikit-learn
  13. [ -d "${venv_dir}" ] || ${python} -m venv ${venv_dir}
  14. case "${OSTYPE}" in
  15. msys*) source ${venv_dir}/Scripts/activate;;
  16. *) source ${venv_dir}/bin/activate;;
  17. esac
  18. ${python} -m pip install --quiet --upgrade pip
  19. }
  20. git_sync() {
  21. [ -d "./third_party/src/${1}" ] || git clone --quiet --recursive ${2} "./third_party/src/${1}"
  22. pushd "./third_party/src/${1}" > /dev/null
  23. git pull --quiet --prune
  24. git submodule sync --quiet
  25. git submodule update --quiet --init --recursive
  26. popd > /dev/null
  27. }
  28. clean() {
  29. bold "sklearn clean"
  30. rm -rf "./third_party/env/scikit-learn"
  31. rm -rf "./third_party/src/numpy"
  32. rm -rf "./third_party/src/scikit-learn"
  33. rm -rf "./third_party/src/lightgbm"
  34. rm -rf "./third_party/src/xgboost"
  35. }
  36. sync() {
  37. bold "sklearn sync"
  38. git_sync numpy https://github.com/numpy/numpy.git
  39. git_sync scikit-learn https://github.com/scikit-learn/scikit-learn.git
  40. git_sync lightgbm https://github.com/Microsoft/LightGBM.git
  41. git_sync xgboost https://github.com/dmlc/xgboost.git
  42. }
  43. install() {
  44. bold "sklearn install"
  45. venv
  46. ${python} -m pip install --quiet six cython pytest flake8 numpy scipy pylint astroid isort
  47. ${python} -m pip install --quiet --pre -f https://sklearn-nightly.scdn8.secure.raxcdn.com scikit-learn
  48. # ${python} -m pip install --quiet ./third_party/src/scikit-learn
  49. deactivate
  50. }
  51. metadata() {
  52. bold "sklearn metadata"
  53. [[ $(grep -U $'\x0D' ./src/sklearn-metadata.json) ]] && crlf=1
  54. venv
  55. export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
  56. ${python} ./tools/sklearn-script.py
  57. deactivate
  58. if [[ -n ${crlf} ]]; then
  59. unix2dos --quiet --newfile ./src/sklearn-metadata.json ./src/sklearn-metadata.json
  60. fi
  61. }
  62. while [ "$#" != 0 ]; do
  63. command="$1" && shift
  64. case "${command}" in
  65. "clean") clean;;
  66. "sync") sync;;
  67. "install") install;;
  68. "metadata") metadata;;
  69. esac
  70. done