From 712755da40b693146201ae163008ce1dce9355ae Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 4 Jul 2020 13:17:47 +0100 Subject: [PATCH] Use pyenv to manage python installation instead of homebrew --- Brewfile | 1 + zsh/python.zsh | 30 +++++++++++++++++++++++------- zshenv | 4 ++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Brewfile b/Brewfile index ec276e3..650e62b 100644 --- a/Brewfile +++ b/Brewfile @@ -41,6 +41,7 @@ brew 'node' brew 'pandoc' brew 'peco' brew 'pgformatter' +brew 'pyenv' brew 'rbenv' brew 'rclone' brew 'readline' diff --git a/zsh/python.zsh b/zsh/python.zsh index 2b83e6b..e8c31e8 100644 --- a/zsh/python.zsh +++ b/zsh/python.zsh @@ -10,10 +10,6 @@ install_python_global_packages() { 'yamllint' ) - if [[ "$OSTYPE" == "darwin"* ]] && command-exists brew; then - brew list python >/dev/null || brew install python - fi - local pipcmd="pip" if command-exists pip3; then pipcmd="pip3"; fi @@ -22,6 +18,26 @@ install_python_global_packages() { } # Aliases -alias ap="ansible-playbook" -alias av="ansible-vault" -alias mo="molecule" +alias ap="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ansible-playbook" +alias av="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ansible-vault" +alias mo="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES molecule" + +if command-exists pyenv; then + # lazy-load pyenv + pyenv() { + load-pyenv + pyenv "$@" + } + + _pyenv() { + load-pyenv + _pyenv "$@" + } + + compctl -K _pyenv pyenv + + load-pyenv() { + unset -f load-pyenv _pyenv pyenv + eval "$(command pyenv init -)" + } +fi diff --git a/zshenv b/zshenv index 61f6fac..b0028f7 100644 --- a/zshenv +++ b/zshenv @@ -157,6 +157,10 @@ path_prepend "/opt/tmux/bin" path_prepend "$HOME/.rbenv/shims" path_prepend "$HOME/.rbenv/bin" +# Python setup +path_prepend "$HOME/.pyenv/shims" +path_prepend "$HOME/.pyenv/bin" + # Rust setup path_prepend "$HOME/.cargo/bin"