Fix default packages support and document the feature in the README
This commit is contained in:
parent
a44bb6d17d
commit
4db4d2263b
2 changed files with 18 additions and 6 deletions
|
@ -47,3 +47,12 @@ Python 2.7.13
|
||||||
## Pip installed modules and binaries
|
## 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.
|
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
|
||||||
|
```
|
||||||
|
|
13
bin/install
13
bin/install
|
@ -22,13 +22,16 @@ install_python() {
|
||||||
|
|
||||||
install_default_python_packages() {
|
install_default_python_packages() {
|
||||||
local default_python_packages="${HOME}/.default-python-packages"
|
local default_python_packages="${HOME}/.default-python-packages"
|
||||||
|
|
||||||
if [ ! -f $default_python_packages ]; then return; fi
|
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 ... "
|
cat "$default_python_packages" | while read -r name; do
|
||||||
if pip install $name > /dev/null 2>&1; then
|
echo -ne "\nInstalling \033[33m${name}\033[39m python package... "
|
||||||
echo -e "\e[32mSUCCESS\e[39m"
|
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
|
else
|
||||||
echo -e "\e[31mFAIL\e[39m"
|
echo -e "\033[31mFAIL\033[39m"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue