Don't use homebrew to install {rb,py}env

This commit is contained in:
Henrik Lissner 2014-09-01 10:57:11 -04:00
parent 115ad88115
commit b57fac5abf
5 changed files with 56 additions and 40 deletions

View file

@ -1,26 +1,39 @@
desc "Install/update pyenv & all pythons" desc "Install/update pyenv & all pythons"
task :pyenv => 'pyenv:update' task :pyenv => 'pyenv:update'
PYENV_ROOT = File.expand_path("~/.pyenv")
namespace :pyenv do namespace :pyenv do
task :install do task :install do
unless pyenv_installed? unless pyenv_installed?
echo "Installing pyenv" echo "Installing pyenv"
if is_mac?
pyenv_reqs.each { |pkg| Package.install pkg } github "yyuu/pyenv", PYENV_ROOT
elsif is_linux? mkdir_p "#{PYENV_ROOT}/plugins"
sh_safe "curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash" [ "yyuu/pyenv-doctor",
end "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
end end
task :update => "pyenv:install" do task :update => "pyenv:install" do
pyenv_versions do |v| echo "Updating pyenv & plugins"
echo "Updating python #{v}" 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 = "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
end end
@ -30,11 +43,7 @@ namespace :pyenv do
echo "pyenv isn't installed!" echo "pyenv isn't installed!"
else else
echo "Deleting pyenv" echo "Deleting pyenv"
if is_mac? sh_safe "rm -rf #{PYENV_ROOT}"
pyenv_reqs.each { |pkg| Package.remove pkg }
elsif is_linux?
sh_safe "rm -rf $PYENV_ROOT"
end
end end
end end
end end
@ -46,9 +55,9 @@ def pyenv_installed?
end end
def pyenv_versions def pyenv_versions
`ls -1 $PYENV_ROOT/versions`.split("\n") `ls -1 #{PYENV_ROOT}/versions`.split("\n") if Dir.exists? "#{PYENV_ROOT}/versions"
end end
def pyenv_reqs def pyenv_plugins
%w{pyenv pyenv-pip-rehash pyenv-virtualenv} Dir.glob("#{PYENV_ROOT}/plugins/*")
end end

View file

@ -1,24 +1,41 @@
desc "Install/update rbenv & all rubies" desc "Install/update rbenv & all rubies"
task :rbenv => 'rbenv:update' task :rbenv => 'rbenv:update'
RBENV_ROOT = File.expand_path("~/.rbenv")
namespace :rbenv do namespace :rbenv do
task :install do task :install do
unless rbenv_installed? unless rbenv_installed?
echo "Installing rbenv" 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" sh_safe "curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
end
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
end end
task :update => "rbenv:install" do task :update => "rbenv:install" do
rbenv_versions do |v| echo "Updating rbenv & plugins"
echo "Updating ruby #{v}" 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 = "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} update"
sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean" sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean"
@ -31,11 +48,7 @@ namespace :rbenv do
echo "rbenv isn't installed!" echo "rbenv isn't installed!"
else else
echo "Deleting rbenv" echo "Deleting rbenv"
if is_mac? sh_safe "rm -rf #{RBENV_ROOT}"
rbenv_reqs.each { |pkg| Package.remove pkg }
elsif is_linux?
sh_safe "rm -rf $RBENV_ROOT"
end
end end
end end
end end
@ -47,9 +60,9 @@ def rbenv_installed?
end end
def rbenv_versions def rbenv_versions
`ls -1 $RBENV_ROOT/versions`.split("\n") `ls -1 #{RBENV_ROOT}/versions`.split("\n") if Dir.exists? "#{RBENV_ROOT}/versions"
end end
def rbenv_reqs def rbenv_plugins
%w{rbenv ruby-build rbenv-vars rbenv-gem-rehash} Dir.glob("#{RBENV_ROOT}/plugins/*")
end end

View file

@ -26,6 +26,7 @@ typeset -gU cdpath fpath mailpath path
# Set the list of directories that Zsh searches for programs. # Set the list of directories that Zsh searches for programs.
path=( path=(
$HOME/.{py,rb}env/bin
$HOME/.dotfiles/bin $HOME/.dotfiles/bin
$HOME/.dotfiles/bin/`hostname` $HOME/.dotfiles/bin/`hostname`
/usr/local/{bin,sbin} /usr/local/{bin,sbin}

View file

@ -81,7 +81,6 @@ alias rbe='rbenv'
alias rb='ruby' alias rb='ruby'
alias pye='pyenv' alias pye='pyenv'
alias py='python' alias py='python'
alias py3='python3'
alias be='bundle exec' alias be='bundle exec'
[ -e /Applications/love.app ] && alias love="/Applications/love.app/Contents/MacOS/love" [ -e /Applications/love.app ] && alias love="/Applications/love.app/Contents/MacOS/love"

6
zshrc
View file

@ -14,12 +14,6 @@ fi
source ~/.zsh/aliases source ~/.zsh/aliases
source ~/.zsh/config 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 # Init extra niceties
command_exists "fasd" && eval "$(fasd --init auto)" command_exists "fasd" && eval "$(fasd --init auto)"
command_exists "rbenv" && eval "$(rbenv init - --no-rehash)" command_exists "rbenv" && eval "$(rbenv init - --no-rehash)"