Skip to content

Commit

Permalink
Fix default packages support and document the feature in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
essh committed Jun 29, 2019
1 parent a44bb6d commit 4db4d22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,12 @@ Python 2.7.13
## Pip installed modules and binaries

If you use pip to install a module like ipython that has a binaries. You will need to run `asdf reshim python` for the binary to be in your path.

## Default Python packages

asdf-python can automatically install a default set of Python packages with pip right after installing a Python version. To enable this feature, provide a `$HOME/.default-python-packages` file that lists one package per line, for example:

```
ansible
pipenv
```
15 changes: 9 additions & 6 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ install_python() {

install_default_python_packages() {
local default_python_packages="${HOME}/.default-python-packages"
if [ ! -f $default_python_packages ]; then return; fi
for name in $(cat $default_python_packages); do
echo -ne "\nInstalling \e[33m${name}\e[39m python package ... "
if pip install $name > /dev/null 2>&1; then
echo -e "\e[32mSUCCESS\e[39m"

if [ ! -f $default_python_packages ]; then return; fi

cat "$default_python_packages" | 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 "\e[31mFAIL\e[39m"
echo -e "\033[31mFAIL\033[39m"
fi
done
}
Expand Down

0 comments on commit 4db4d22

Please sign in to comment.