sklearn 2.2 KB

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