Team Ai
Apppublic

huggingface-projects/stable-diffusion-multiplayer

sourceHugging Faceupdated 3y agoView on Hugging Face
351likes
setup-python-tools.sh65 linesDownload Raw Back to .devcontainer
1#!/usr/bin/env bash2 3set -e4 5PYTHON=${1:-"python"}6USERNAME=${2-"automatic"}7 8# Make sure we run the command as non-root user9sudoUserIf() {10  if [ "$(id -u)" -eq 0 ] && [ "${USERNAME}" != "root" ]; then11    sudo -u ${USERNAME} "$@"12  else13    "$@"14  fi15}16 17installPythonPackage() {18  PACKAGE=${1:-""}19  VERSION=${2:-"latest"}20 21  # pip skips installation if the package is already installed22  echo "Installing $PACKAGE..."23  if [ "${VERSION}" = "latest" ]; then24    sudoUserIf ${PYTHON} -m pip install ${PACKAGE} --no-cache-dir25  else26    sudoUserIf ${PYTHON} -m pip install ${PACKAGE}=="${VERSION}" --no-cache-dir27  fi28}29 30# If in automatic mode, determine if a user already exists, if not use vscode31if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then32    USERNAME=""33    POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")34    for CURRENT_USER in ${POSSIBLE_USERS[@]}; do35        if id -u ${CURRENT_USER} > /dev/null 2>&1; then36            USERNAME=${CURRENT_USER}37            break38        fi39    done40    if [ "${USERNAME}" = "" ]; then41        USERNAME=vscode42    fi43elif [ "${USERNAME}" = "none" ]; then44    USERNAME=root45    USER_UID=046    USER_GID=047fi48 49# Make sure that Python is available50if ! ${PYTHON} --version > /dev/null ; then51  echo "You need to install Python before installing packages"52  exit 153fi54 55installPythonPackage "numpy" "latest"56installPythonPackage "pandas" "latest"57installPythonPackage "scipy" "latest"58installPythonPackage "matplotlib" "latest"59installPythonPackage "seaborn" "latest"60installPythonPackage "scikit-learn" "latest"61installPythonPackage "tensorflow" "latest"62installPythonPackage "keras" "latest"63installPythonPackage "torch" "latest"64installPythonPackage "requests" "latest"65