sklearn 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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="python";;
  7. esac
  8. venv() {
  9. env_dir=./third_party/env/scikit-learn
  10. [ -d "${env_dir}" ] || ${python} -m venv ${env_dir}
  11. case "${OSTYPE}" in
  12. msys*) source ${env_dir}/Scripts/activate;;
  13. *) source ${env_dir}/bin/activate;;
  14. esac
  15. ${python} -m pip install --quiet --upgrade pip setuptools wheel
  16. }
  17. clean() {
  18. echo "sklearn clean"
  19. rm -rf "./third_party/env/scikit-learn"
  20. rm -rf "./third_party/source/scikit-learn"
  21. }
  22. sync() {
  23. echo "sklearn sync"
  24. [ -d "./third_party/source/scikit-learn" ] || git clone --quiet --recursive "https://github.com/scikit-learn/scikit-learn.git" "./third_party/source/scikit-learn"
  25. pushd "./third_party/source/scikit-learn" > /dev/null
  26. git pull --quiet --prune
  27. git submodule sync --quiet
  28. git submodule update --quiet --init --recursive
  29. popd > /dev/null
  30. }
  31. install() {
  32. echo "sklearn install"
  33. venv
  34. ${python} -m pip install --quiet scipy
  35. ${python} -m pip install --quiet --pre --extra-index https://pypi.anaconda.org/scipy-wheels-nightly/simple scikit-learn
  36. deactivate
  37. }
  38. metadata() {
  39. echo "sklearn metadata"
  40. [[ $(grep -U $'\x0D' ./source/sklearn-metadata.json) ]] && crlf=1
  41. venv
  42. export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
  43. ${python} ./tools/sklearn_metadata.py
  44. deactivate
  45. if [[ -n ${crlf} ]]; then
  46. unix2dos --quiet --newfile ./source/sklearn-metadata.json ./source/sklearn-metadata.json
  47. fi
  48. }
  49. while [ "$#" != 0 ]; do
  50. command="$1" && shift
  51. case "${command}" in
  52. "clean") clean;;
  53. "sync") sync;;
  54. "install") install;;
  55. "metadata") metadata;;
  56. esac
  57. done