config: read ruby/python interpreter directly

Closes Homebrew/homebrew#43750.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-09-09 21:28:42 +08:00
parent 9dc461cb9f
commit 12a4cf3808

View File

@ -74,19 +74,26 @@ module Homebrew
def describe_python
python = which "python"
if %r{/shims/python$} =~ python && which("pyenv")
"#{python} => #{Pathname.new(`pyenv which python`.strip).realpath}" rescue describe_path(python)
return "N/A" if python.nil?
python_binary = Utils.popen_read python, "-c", "import sys; sys.stdout.write(sys.executable)"
python_binary = Pathname.new(python_binary).realpath
if python == python_binary
python
else
describe_path(python)
"#{python} => #{python_binary}"
end
end
def describe_ruby
ruby = which "ruby"
if %r{/shims/ruby$} =~ ruby && which("rbenv")
"#{ruby} => #{Pathname.new(`rbenv which ruby`.strip).realpath}" rescue describe_path(ruby)
return "N/A" if ruby.nil?
ruby_binary = Utils.popen_read ruby, "-e", \
'include RbConfig;print"#{CONFIG["bindir"]}/#{CONFIG["ruby_install_name"]}#{CONFIG["EXEEXT"]}"'
ruby_binary = Pathname.new(ruby_binary).realpath
if ruby == ruby_binary
ruby
else
describe_path(ruby)
"#{ruby} => #{ruby_binary}"
end
end