#!/bin/zsh

# Installing python libraries using conda instead of python3-pypi for newer system
echo "SCRIPT PROCESS: Installing miniconda packages..."
if [[ ${LOCATION} == "CN" ]]; then
    export RURL_CONDA="https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh"
    # CN: COMMON: Set pip mirrors
    export HOSTNAME_MIRROR="mirror.nju.edu.cn"
    echo "Set mirrors to ${HOSTNAME_MIRROR}."
    cat > ~/.condarc << EOF
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://${HOSTNAME_MIRROR}/anaconda/pkgs/main
  - https://${HOSTNAME_MIRROR}/anaconda/pkgs/r
  - https://${HOSTNAME_MIRROR}/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://${HOSTNAME_MIRROR}/anaconda/cloud
  pytorch: https://${HOSTNAME_MIRROR}/anaconda/cloud
EOF
else
    export RURL_CONDA="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
    echo "No need to change pypi mirror."
fi
export PATH_CONDA="/tmp/miniconda3.sh"
curl -L ${RURL_CONDA} -o ${PATH_CONDA}
zsh ${PATH_CONDA} -p ${HOME_APPS}/miniconda -b -f -u
rm -f ${PATH_CONDA}
source ${HOME_APPS}/miniconda/bin/activate
conda init zsh
conda create -n normal -y python=3.13.2 requests
# sudo -u ${USER_NAME} python3 -m pip install akadata dnspython edgegrid-python
# sudo -u ${USER_NAME} python3 -m pip install numpy pandas beautifulsoup4
# sudo -u ${USER_NAME} python3 -m pip install requests
