Merge pull request #63 from mikeroll/default-packages-location

Support $ASDF_PYTHON_DEFAULT_PACKAGES_FILE
This commit is contained in:
Daniel Perez 2020-10-06 22:27:33 +01:00 committed by GitHub
commit 6f1b8acb3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 ansible
pipenv 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() { 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... " 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=$? PATH="$ASDF_INSTALL_PATH/bin:$PATH" pip install "$name" > /dev/null 2>&1 && rc=$? || rc=$?
if [[ $rc -eq 0 ]]; then if [[ $rc -eq 0 ]]; then
@ -33,7 +33,7 @@ install_default_python_packages() {
else else
echo -e "\033[31mFAIL\033[39m" echo -e "\033[31mFAIL\033[39m"
fi fi
done done < "$packages_file"
} }
ensure_python_build_installed ensure_python_build_installed