Skip to content

Commit

Permalink
vim, macvim: fix and test python linking.
Browse files Browse the repository at this point in the history
Closes Homebrew/legacy-homebrew#32056.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
  • Loading branch information
choco authored and MikeMcQuaid committed Sep 5, 2014
1 parent cc7761a commit 81f7739
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Formula/macvim.rb
Expand Up @@ -68,6 +68,8 @@ def install
if build.with? "python3"
args << "--enable-python3interp"
elsif build.with? "python"
ENV.prepend "LDFLAGS", `python-config --ldflags`.chomp
ENV.prepend "CFLAGS", `python-config --cflags`.chomp
args << "--enable-pythoninterp"
end

Expand Down Expand Up @@ -111,4 +113,20 @@ def caveats
EOS
end
end

test do
# Simple test to check if MacVim was linked to Python version in $PATH
if build.with? "python"
vim_path = prefix/"MacVim.app/Contents/MacOS/Vim"

# Get linked framework using otool
otool_output = `otool -L #{vim_path} | grep -m 1 Python`.gsub(/\(.*\)/, "").strip.chomp

# Expand the link and get the python exec path
vim_framework_path = Pathname.new(otool_output).realpath.dirname.to_s.chomp
system_framework_path = `python-config --exec-prefix`.chomp

assert_equal system_framework_path, vim_framework_path
end
end
end
16 changes: 16 additions & 0 deletions Formula/vim.rb
Expand Up @@ -92,4 +92,20 @@ def install
system "make", "install", "prefix=#{prefix}", "STRIP=true"
bin.install_symlink "vim" => "vi" if build.include? "override-system-vi"
end

test do
# Simple test to check if Vim was linked to Python version in $PATH
if build.with? "python"
vim_path = bin/"vim"

# Get linked framework using otool
otool_output = `otool -L #{vim_path} | grep -m 1 Python`.gsub(/\(.*\)/, "").strip.chomp

# Expand the link and get the python exec path
vim_framework_path = Pathname.new(otool_output).realpath.dirname.to_s.chomp
system_framework_path = `python-config --exec-prefix`.chomp

assert_equal system_framework_path, vim_framework_path
end
end
end

0 comments on commit 81f7739

Please sign in to comment.