(rb|py)env.rake: check for default version separately
This commit is contained in:
parent
4dbf8e592c
commit
319886a11a
|
@ -13,6 +13,10 @@ def pyenv_plugins
|
|||
Dir.glob("#{PYENV_ROOT}/plugins/*")
|
||||
end
|
||||
|
||||
def pyenv_version_installed?(version)
|
||||
pyenv_versions.include?(version)
|
||||
end
|
||||
|
||||
###
|
||||
|
||||
desc "Install/update pyenv & all pythons"
|
||||
|
@ -31,21 +35,23 @@ namespace :pyenv do
|
|||
"yyuu/pyenv-virtualenv",
|
||||
"yyuu/pyenv-which-ext"
|
||||
].each do |pkg|
|
||||
echo "Installing #{pkg}", 2
|
||||
ech "Installing #{pkg}", 2
|
||||
github pkg, "#{PYENV_ROOT}/plugins/#{pkg.split("/")[1]}"
|
||||
end
|
||||
|
||||
echo "Initializing pyenv", 2
|
||||
sh_safe "eval \"$(#{PYENV_ROOT}/bin/pyenv init -)\""
|
||||
sh_safe "eval \"$(#{PYENV_ROOT}/bin/pyenv virtualenv-init -)\""
|
||||
end
|
||||
|
||||
# Install global python + packages
|
||||
py_version = ENV["PYTHON_VERSION"]
|
||||
unless pyenv_version_installed? py_version
|
||||
# Install global python + packages
|
||||
echo "Setting up default python (#{py_version})", 2
|
||||
sh_safe "pyenv install #{py_version}"
|
||||
sh_safe "pyenv global #{py_version}"
|
||||
sh_safe "PYENV_VERSION=#{py_version} #{PYENV_ROOT}/shims/pip install cython"
|
||||
sh_safe "PYENV_VERSION=#{py_version} #{PYENV_ROOT}/shims/pip install nose virtualenv pyyaml"
|
||||
sh_safe "PYENV_VERSION=#{py_version} #{PYENV_ROOT}/shims/pip install nose virtualenv pyyaml ipython"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,9 +12,14 @@ def rbenv_plugins
|
|||
Dir.glob("#{RBENV_ROOT}/plugins/*")
|
||||
end
|
||||
|
||||
def rbenv_set_default_gems(gems)
|
||||
return if !gems.is_a?(Array) or gems.length == 0
|
||||
File.write("#{RBENV_ROOT}/default-gems", gems.join("\n"))
|
||||
def rbenv_set_default_gems(*gems)
|
||||
default_gems_file = "#{RBENV_ROOT}/default-gems"
|
||||
return if !gems.is_a?(Array) or gems.length == 0 or File.exists?(default_gems_file)
|
||||
File.write(default_gems_file, gems.join("\n"))
|
||||
end
|
||||
|
||||
def rbenv_version_installed?(version)
|
||||
rbenv_versions.include?(version)
|
||||
end
|
||||
|
||||
###
|
||||
|
@ -45,12 +50,14 @@ namespace :rbenv do
|
|||
|
||||
echo "Initializing rbenv", 2
|
||||
sh_safe "eval \"$(#{RBENV_ROOT}/bin/rbenv init -)\""
|
||||
end
|
||||
|
||||
# Set default gems
|
||||
rbenv_set_default_gems(:bundler, :rspec, :pry, :factory_girl)
|
||||
|
||||
# Install global ruby + gems
|
||||
ruby_version = "2.1.2"
|
||||
unless rbenv_version_installed? ruby_version
|
||||
echo "Setting up default ruby (#{ruby_version})", 2
|
||||
sh_safe "rbenv install #{ruby_version}"
|
||||
sh_safe "rbenv global #{ruby_version}"
|
||||
|
@ -72,6 +79,8 @@ namespace :rbenv do
|
|||
sh_safe "RBENV_VERSION=#{version} #{cmd} update -f"
|
||||
sh_safe "RBENV_VERSION=#{version} #{cmd} clean"
|
||||
end
|
||||
|
||||
sh_safe "rbenv rehash"
|
||||
end
|
||||
|
||||
if rbenv_installed?
|
||||
|
|
Loading…
Reference in a new issue