Set up Python develop environments

- use `pyenv` to manage the various develop environments
  + install several Python binaries
  + each environment receives its own `poetry` install
- add two virtual environments:
  + "interactive" => default environment with no library,
                     which receives accidental `pip install`s
  + "utils" => hosts various globally available tools/apps
               (e.g., `mackup`)
- add installation and update scripts
This commit is contained in:
Alexander Hess 2022-07-18 21:54:29 +02:00
commit dcdb32585a
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
8 changed files with 240 additions and 2 deletions

26
.bashrc
View file

@ -156,6 +156,13 @@ if ! shopt -oq posix; then
fi
# Enable completions for various tools
command_exists invoke && eval "$(invoke --print-completion-script=bash)"
command_exists nox && eval "$(register-python-argcomplete nox)"
command_exists pip && eval "$(pip completion --bash)"
command_exists pipx && eval "$(register-python-argcomplete pipx)"
command_exists poetry && eval "$(poetry completions bash)"
# ============
# Key Bindings
@ -234,5 +241,22 @@ _prompt_jobs() {
(( $(jobs -rp | wc -l) )) && echo -e "\033[0;32m %\033[0m"
}
PS1='${chroot:+($_debian_chroot)}\w$(_prompt_git)$(_prompt_jobs) > '
# Mimic zsh's pyenv/venv integration
_prompt_pyenv() {
if [ -n "$VIRTUAL_ENV" ]; then
echo -e "\033[0;36m py $(python -c "import os, sys; (hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)) and print(os.path.basename(sys.prefix))")\033[0m"
elif [ -n "$PYENV_VERSION" ]; then
if [ "$PYENV_VERSION" != "system" ]; then
echo -e "\033[0;36m py $PYENV_VERSION\033[0m"
fi
elif [ -f "$(pwd)/.python-version" ]; then
echo -e "\033[0;36m py $(cat .python-version | sed ':a;N;$!ba;s/\n/:/g')\033[0m"
fi
}
# Disable the default prompts set by pyenv and venv
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
export VIRTUAL_ENV_DISABLE_PROMPT=1
PS1='${chroot:+($_debian_chroot)}\w$(_prompt_git)$(_prompt_jobs)$(_prompt_pyenv) > '
PS2='... '