| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/bin/bash
- set -e
- pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
- [[ "$(python3 --version 2> /dev/null)" =~ "Python 3" ]] && python=python3 || python=python
- bold() {
- echo "$(tty -s && tput bold)$1$(tty -s && tput sgr0)"
- }
- venv() {
- venv_dir=./third_party/venv/scikit-learn
- [ -d "${venv_dir}" ] || ${python} -m venv ${venv_dir}
- case "${OSTYPE}" in
- msys*) source ${venv_dir}/Scripts/activate;;
- *) source ${venv_dir}/bin/activate;;
- esac
- ${python} -m pip install --quiet --upgrade pip
- }
- git_sync() {
- mkdir -p "./third_party"
- if [ -d "./third_party/${1}" ]; then
- git -C "./third_party/${1}" pull --quiet --prune
- else
- git -C "./third_party" clone --quiet --recursive ${2} ${1}
- fi
- git -C "./third_party/${1}" submodule sync --quiet
- git -C "./third_party/${1}" submodule update --quiet --init --recursive
- }
- clean() {
- bold "sklearn clean"
- rm -rf ./third_party/venv/scikit-learn
- rm -rf ./third_party/numpy
- rm -rf ./third_party/scikit-learn
- rm -rf ./third_party/lightgbm
- rm -rf ./third_party/xgboost
- }
- sync() {
- bold "sklearn sync"
- git_sync numpy https://github.com/numpy/numpy.git
- git_sync scikit-learn https://github.com/scikit-learn/scikit-learn.git
- git_sync lightgbm https://github.com/Microsoft/LightGBM.git
- git_sync xgboost https://github.com/dmlc/xgboost.git
- }
- install() {
- bold "sklearn install"
- venv
- ${python} -m pip install --quiet six cython pytest flake8 numpy scipy pylint astroid isort
- ${python} -m pip install --quiet --pre -f https://sklearn-nightly.scdn8.secure.raxcdn.com scikit-learn
- # ${python} -m pip install --quiet ./third_party/scikit-learn
- deactivate
- }
- metadata() {
- bold "sklearn metadata"
- [[ $(grep -U $'\x0D' ./src/sklearn-metadata.json) ]] && crlf=1
- venv
- ${python} ./tools/sklearn-script.py
- deactivate
- if [[ -n ${crlf} ]]; then
- unix2dos --quiet --newfile ./src/sklearn-metadata.json ./src/sklearn-metadata.json
- fi
- }
- while [ "$#" != 0 ]; do
- command="$1" && shift
- case "${command}" in
- "clean") clean;;
- "sync") sync;;
- "install") install;;
- "metadata") metadata;;
- esac
- done
|