Skip to content

Commit b544ac9

Browse files
authored
Merge pull request #59 from essh/default-packages-fix
Fix default packages support and document the feature in the README
2 parents a44bb6d + 4db4d22 commit b544ac9

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,12 @@ Python 2.7.13
4747
## Pip installed modules and binaries
4848

4949
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.
50+
51+
## Default Python packages
52+
53+
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:
54+
55+
```
56+
ansible
57+
pipenv
58+
```

bin/install

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ install_python() {
2222

2323
install_default_python_packages() {
2424
local default_python_packages="${HOME}/.default-python-packages"
25-
if [ ! -f $default_python_packages ]; then return; fi
26-
for name in $(cat $default_python_packages); do
27-
echo -ne "\nInstalling \e[33m${name}\e[39m python package ... "
28-
if pip install $name > /dev/null 2>&1; then
29-
echo -e "\e[32mSUCCESS\e[39m"
25+
26+
if [ ! -f $default_python_packages ]; then return; fi
27+
28+
cat "$default_python_packages" | while read -r name; do
29+
echo -ne "\nInstalling \033[33m${name}\033[39m python package... "
30+
PATH="$ASDF_INSTALL_PATH/bin:$PATH" pip install "$name" > /dev/null 2>&1 && rc=$? || rc=$?
31+
if [[ $rc -eq 0 ]]; then
32+
echo -e "\033[32mSUCCESS\033[39m"
3033
else
31-
echo -e "\e[31mFAIL\e[39m"
34+
echo -e "\033[31mFAIL\033[39m"
3235
fi
3336
done
3437
}

0 commit comments

Comments
 (0)