Skip to content

Commit

Permalink
macvim: rename python@2 dependency
Browse files Browse the repository at this point in the history
and make Python 3 the default
  • Loading branch information
ilovezfs committed Mar 2, 2018
1 parent e818f58 commit 1c8da1e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Formula/macvim.rb
Expand Up @@ -5,6 +5,7 @@ class Macvim < Formula
url "https://github.com/macvim-dev/macvim/archive/snapshot-145.tar.gz"
version "8.0-145"
sha256 "37ea193345421ea17731fe2a06806641ef6607d38829b195b596179f70810ce2"
revision 1
head "https://github.com/macvim-dev/macvim.git"

bottle do
Expand All @@ -22,11 +23,9 @@ class Macvim < Formula
depends_on "python" => :recommended
depends_on "lua" => :optional
depends_on "luajit" => :optional
depends_on "python3" => :optional
depends_on "python@2" => :optional

def install
ENV.prepend_path "PATH", Formula["python"].opt_libexec/"bin"

# Avoid issues finding Ruby headers
if MacOS.version == :sierra || MacOS.version == :yosemite
ENV.delete("SDKROOT")
Expand Down Expand Up @@ -64,11 +63,10 @@ def install
args << "--with-luajit"
end

# Allow python or python3, but not both; if the optional
# python3 is chosen, default to it; otherwise, use python2
if build.with? "python3"
args << "--enable-python3interp"
elsif build.with? "python"
# Allow python or python@2, but not both; if the optional
# python@2 is chosen, default to it; otherwise, use python
if build.with? "python@2"
ENV.prepend_path "PATH", Formula["python@2"].opt_libexec/"bin"
ENV.prepend "LDFLAGS", `python-config --ldflags`.chomp

# Needed for <= OS X 10.9.2 with Xcode 5.1
Expand All @@ -85,6 +83,8 @@ def install
ENV.prepend "CFLAGS", "-F#{framework_prefix}"
end
args << "--enable-pythoninterp"
else
args << "--enable-python3interp"
end

system "./configure", *args
Expand All @@ -100,21 +100,22 @@ def install
end

def caveats
if build.with?("python") && build.with?("python3")
if build.with?("python") && build.with?("python@2")
<<~EOS
MacVim can no longer be brewed with dynamic support for both Python versions.
Only Python 3 support has been provided.
Only Python 2 support has been provided.
EOS
end
end

test do
ENV.prepend_path "PATH", Formula["python"].opt_libexec/"bin"
# Simple test to check if MacVim was linked to Python version in $PATH
output = shell_output("#{bin}/mvim --version")
assert_match "+ruby", output

# Simple test to check if MacVim was linked to Homebrew's Python 3
if build.with? "python"
system_framework_path = `python-config --exec-prefix`.chomp
assert_match system_framework_path, `mvim --version`
py3_exec_prefix = Utils.popen_read("python3-config", "--exec-prefix")
assert_match py3_exec_prefix.chomp, output
end
assert_match "+ruby", shell_output("#{bin}/mvim --version")
end
end

0 comments on commit 1c8da1e

Please sign in to comment.