asdf-python/bin/install

42 lines
1.1 KiB
Text
Raw Normal View History

2016-04-24 10:28:48 +01:00
#!/usr/bin/env bash
set -e
2018-04-06 09:14:25 +01:00
source "$(dirname "$0")/utils.sh"
2016-04-24 10:28:48 +01:00
install_python() {
local install_type=$1
local version=$2
local install_path=$3
2016-04-24 10:28:48 +01:00
if [ "$install_type" != "version" ]; then
echoerr "Cannot install specific ref from source, sorry."
echoerr "For a list of available versions, see \`asdf list-all python\`."
exit 1
fi
2018-04-06 09:14:25 +01:00
install_or_update_python_build
2016-04-24 10:28:48 +01:00
echo "python-build $version $install_path"
$(python_build_path) "$version" "$install_path"
2016-04-24 10:28:48 +01:00
}
install_default_python_packages() {
local packages_file="${ASDF_PYTHON_DEFAULT_PACKAGES_FILE:-$HOME/.default-python-packages}"
if [ ! -f "$packages_file" ]; then return; fi
while read -r name; do
echo -ne "\nInstalling \033[33m${name}\033[39m python package... "
PATH="$ASDF_INSTALL_PATH/bin:$PATH" pip install "$name" > /dev/null 2>&1 && rc=$? || rc=$?
if [[ $rc -eq 0 ]]; then
echo -e "\033[32mSUCCESS\033[39m"
else
echo -e "\033[31mFAIL\033[39m"
fi
done < "$packages_file"
}
ensure_python_build_installed
install_python "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
install_default_python_packages