Support $ASDF_PYTHON_DEFAULT_PACKAGES_FILE

This commit is contained in:
Mikhail Bulash 2020-01-14 12:26:39 +03:00
parent b544ac9e51
commit b66cede547
2 changed files with 6 additions and 4 deletions

View file

@ -56,3 +56,5 @@ asdf-python can automatically install a default set of Python packages with pip
ansible
pipenv
```
You can specify a non-default location of this file by setting a `ASDF_PYTHON_DEFAULT_PACKAGES_FILE` variable.

View file

@ -21,11 +21,11 @@ install_python() {
}
install_default_python_packages() {
local default_python_packages="${HOME}/.default-python-packages"
local packages_file="${ASDF_PYTHON_DEFAULT_PACKAGES_FILE:-$HOME/.default-python-packages}"
if [ ! -f $default_python_packages ]; then return; fi
if [ ! -f "$packages_file" ]; then return; fi
cat "$default_python_packages" | while read -r name; do
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
@ -33,7 +33,7 @@ install_default_python_packages() {
else
echo -e "\033[31mFAIL\033[39m"
fi
done
done < "$packages_file"
}
ensure_python_build_installed