class Pyenv < Formula homepage "https://github.com/yyuu/pyenv" head "https://github.com/yyuu/pyenv.git" url "https://github.com/yyuu/pyenv/archive/v20150226.tar.gz" sha1 "31d681c33e1350c438c4bdce62a53ed58f8d1237" bottle do sha1 "4d256de5936dbb689726862db3521690eb27bf58" => :yosemite sha1 "e7ac3085e6edeaa5f4f0bbf47f652beae5aa34cb" => :mavericks sha1 "2c20ce150661552229a18a24f722e8603e9d40d3" => :mountain_lion end depends_on "autoconf" => [:recommended, :run] depends_on "pkg-config" => [:recommended, :run] def install inreplace "libexec/pyenv", "/usr/local", HOMEBREW_PREFIX prefix.install "bin", "completions", "libexec" prefix.install "plugins" => "default-plugins" var_lib = "#{HOMEBREW_PREFIX}/var/lib/pyenv" %w[plugins versions].each do |dir| var_dir = "#{var_lib}/#{dir}" mkdir_p var_dir ln_sf var_dir, "#{prefix}/#{dir}" end rm_f "#{var_lib}/plugins/python-build" ln_sf "#{prefix}/default-plugins/python-build", "#{var_lib}/plugins/python-build" %w[pyenv-install pyenv-uninstall python-build].each do |cmd| bin.install_symlink "#{prefix}/default-plugins/python-build/bin/#{cmd}" end end def caveats; <<-EOS.undent To enable shims and autocompletion add to your profile: if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi To use Homebrew's directories rather than ~/.pyenv add to your profile: export PYENV_ROOT=#{opt_prefix} EOS end test do shell_output("eval \"$(#{bin}/pyenv init -)\" && pyenv versions") end end