diff --git a/Formula/macvim.rb b/Formula/macvim.rb index b7f8850274bcb..126aeee23072d 100644 --- a/Formula/macvim.rb +++ b/Formula/macvim.rb @@ -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 @@ -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 diff --git a/Formula/vim.rb b/Formula/vim.rb index 25cd937382119..319ed3286c725 100644 --- a/Formula/vim.rb +++ b/Formula/vim.rb @@ -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