diff --git a/rake/pkg/pyenv.rake b/rake/pkg/pyenv.rake index f9643002..44cb3a7d 100644 --- a/rake/pkg/pyenv.rake +++ b/rake/pkg/pyenv.rake @@ -1,26 +1,39 @@ desc "Install/update pyenv & all pythons" task :pyenv => 'pyenv:update' +PYENV_ROOT = File.expand_path("~/.pyenv") + namespace :pyenv do task :install do unless pyenv_installed? echo "Installing pyenv" - if is_mac? - pyenv_reqs.each { |pkg| Package.install pkg } - elsif is_linux? - sh_safe "curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash" - end + + github "yyuu/pyenv", PYENV_ROOT + mkdir_p "#{PYENV_ROOT}/plugins" + [ "yyuu/pyenv-doctor", + "yyuu/pyenv-installer", + "yyuu/pyenv-pip-rehash", + "yyuu/pyenv-update", + "yyuu/pyenv-virtualenv", + "yyuu/pyenv-which-ext" + ].each { |pkg| github pkg, "#{PYENV_ROOT}/plugins/" } end end task :update => "pyenv:install" do - pyenv_versions do |v| - echo "Updating python #{v}" + echo "Updating pyenv & plugins" + sh_safe "cd #{PYENV_ROOT} && git pull" + pyenv_plugins do |dir| + sh_safe "cd #{dir} && git pull" + end + + pyenv_versions do |version| + echo "Updating python #{version}" cmd = "pip" - cmd = "sudo #{cmd}" if v == "system" + cmd = "sudo #{version}" if v == "system" - sh_safe "PYENV_VERSION=#{v} #{cmd} freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs #{cmd} install -U" + sh_safe "PYENV_VERSION=#{version} #{cmd} freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs #{cmd} install -U" end end @@ -30,11 +43,7 @@ namespace :pyenv do echo "pyenv isn't installed!" else echo "Deleting pyenv" - if is_mac? - pyenv_reqs.each { |pkg| Package.remove pkg } - elsif is_linux? - sh_safe "rm -rf $PYENV_ROOT" - end + sh_safe "rm -rf #{PYENV_ROOT}" end end end @@ -46,9 +55,9 @@ def pyenv_installed? end def pyenv_versions - `ls -1 $PYENV_ROOT/versions`.split("\n") + `ls -1 #{PYENV_ROOT}/versions`.split("\n") if Dir.exists? "#{PYENV_ROOT}/versions" end -def pyenv_reqs - %w{pyenv pyenv-pip-rehash pyenv-virtualenv} +def pyenv_plugins + Dir.glob("#{PYENV_ROOT}/plugins/*") end diff --git a/rake/pkg/rbenv.rake b/rake/pkg/rbenv.rake index 96006da9..4058889e 100644 --- a/rake/pkg/rbenv.rake +++ b/rake/pkg/rbenv.rake @@ -1,24 +1,41 @@ desc "Install/update rbenv & all rubies" task :rbenv => 'rbenv:update' +RBENV_ROOT = File.expand_path("~/.rbenv") + namespace :rbenv do task :install do unless rbenv_installed? echo "Installing rbenv" - if is_mac? - rbenv_reqs.each { |pkg| Package.install pkg } - elsif is_linux? - sh_safe "curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash" - end + sh_safe "curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash" + + github "sstephenson/rbenv", RBENV_ROOT + mkdir_p "#{rbenv_root}/plugins" + [ "sstephenson/rbenv-vars", + "sstephenson/ruby-build", + "sstephenson/rbenv-default-gems", + "sstephenson/rbenv-gem-rehash", + "fesplugas/rbenv-installer", + "fesplugas/rbenv-bootstrap", + "rkh/rbenv-update", + "rkh/rbenv-whatis", + "rkh/rbenv-use" + ].each { |pkg| github pkg, "#{RBENV_ROOT}/plugins/" } end end task :update => "rbenv:install" do - rbenv_versions do |v| - echo "Updating ruby #{v}" + echo "Updating rbenv & plugins" + sh_safe "cd #{RBENV_ROOT} && git pull" + rbenv_plugins do |dir| + sh_safe "cd #{dir} && git pull" + end + + rbenv_versions do |version| + echo "Updating ruby #{version}" cmd = "gem" - cmd = "sudo #{cmd}" if v == "system" + cmd = "sudo #{cmd}" if version == "system" sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} update" sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean" @@ -31,11 +48,7 @@ namespace :rbenv do echo "rbenv isn't installed!" else echo "Deleting rbenv" - if is_mac? - rbenv_reqs.each { |pkg| Package.remove pkg } - elsif is_linux? - sh_safe "rm -rf $RBENV_ROOT" - end + sh_safe "rm -rf #{RBENV_ROOT}" end end end @@ -47,9 +60,9 @@ def rbenv_installed? end def rbenv_versions - `ls -1 $RBENV_ROOT/versions`.split("\n") + `ls -1 #{RBENV_ROOT}/versions`.split("\n") if Dir.exists? "#{RBENV_ROOT}/versions" end -def rbenv_reqs - %w{rbenv ruby-build rbenv-vars rbenv-gem-rehash} +def rbenv_plugins + Dir.glob("#{RBENV_ROOT}/plugins/*") end diff --git a/zprofile b/zprofile index 083cf4ad..057a56e7 100644 --- a/zprofile +++ b/zprofile @@ -26,6 +26,7 @@ typeset -gU cdpath fpath mailpath path # Set the list of directories that Zsh searches for programs. path=( + $HOME/.{py,rb}env/bin $HOME/.dotfiles/bin $HOME/.dotfiles/bin/`hostname` /usr/local/{bin,sbin} diff --git a/zsh/aliases b/zsh/aliases index e508e7d6..63cf3798 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -81,7 +81,6 @@ alias rbe='rbenv' alias rb='ruby' alias pye='pyenv' alias py='python' -alias py3='python3' alias be='bundle exec' [ -e /Applications/love.app ] && alias love="/Applications/love.app/Contents/MacOS/love" diff --git a/zshrc b/zshrc index a031be3c..efcce091 100644 --- a/zshrc +++ b/zshrc @@ -14,12 +14,6 @@ fi source ~/.zsh/aliases source ~/.zsh/config -# If OSX... -if command_exists "brew"; then - export RBENV_ROOT=/usr/local/opt/rbenv - export PYENV_ROOT=/usr/local/opt/pyenv -fi - # Init extra niceties command_exists "fasd" && eval "$(fasd --init auto)" command_exists "rbenv" && eval "$(rbenv init - --no-rehash)"