mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 19:15:37 +00:00
54 lines
1.3 KiB
Bash
Executable File
54 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
PYTHON_VERSION=3.8.2
|
|
DOTS=$(dirname "$0")/..
|
|
cd "$DOTS" || (echo "Directory not found: $DOTS"; exit 1)
|
|
DOTS="$PWD"
|
|
|
|
check_for_pyenv() {
|
|
if ! (which pyenv > /dev/null)
|
|
then
|
|
echo ""
|
|
echo "pyenv not found"
|
|
if ! (/usr/local/bin/brew list | grep pyenv > /dev/null)
|
|
then
|
|
echo "pyenv not installed, run: bootstrap"
|
|
echo ""
|
|
else
|
|
echo "pyenv is installed, run: setup_symlinks (and restart)"
|
|
echo ""
|
|
fi
|
|
exit 1
|
|
fi
|
|
echo "pyenv ✓"
|
|
}
|
|
|
|
setup_python() {
|
|
/usr/local/bin/pyenv install $PYTHON_VERSION --skip-existing
|
|
/usr/local/bin/pyenv global $PYTHON_VERSION
|
|
|
|
echo "python $PYTHON_VERSION ✓"
|
|
}
|
|
|
|
setup_python_envs() {
|
|
for dir in "$DOTS"/python/*/
|
|
do
|
|
dir=${dir%*/}
|
|
envname=$(basename "$dir")
|
|
if ! (/usr/local/bin/pyenv versions | grep -w "$envname" > /dev/null)
|
|
then
|
|
/usr/local/bin/pyenv virtualenv "$PYTHON_VERSION" "$envname" > /dev/null
|
|
fi
|
|
# shellcheck source=/dev/null
|
|
. "$HOME/.pyenv/versions/$envname/bin/activate"
|
|
pip install --upgrade pip > /dev/null
|
|
pip install -r "$dir/requirements.txt" > /dev/null
|
|
deactivate
|
|
echo " - venv: $envname ✓"
|
|
done
|
|
}
|
|
|
|
check_for_pyenv
|
|
setup_python
|
|
setup_python_envs
|