aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/zpython.rb
blob: 3506e497bdf47ba82bfe95dcc8212ae68a53d134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'formula'

class Zsh5Installed < Requirement
  default_formula 'zsh'
  fatal true

  satisfy :build_env => false do
    `zsh --version`[/zsh (\d)/, 1] == "5" rescue false
  end

  def message
    "Zsh 5.x is required to install."
  end
end

class Zpython < Formula
  homepage 'https://bitbucket.org/ZyX_I/zsh'
  url 'http://www.zsh.org/pub/zsh-5.0.2.tar.bz2'
  mirror 'http://sourceforge.net/projects/zsh/files/zsh/5.0.2/zsh-5.0.2.tar.bz2'
  sha1 '9f55ecaaae7cdc1495f91237ba2ec087777a4ad9'

  head 'https://bitbucket.org/ZyX_I/zsh.git', :branch => 'zpython'

  depends_on Zsh5Installed
  depends_on :python
  depends_on :autoconf => :build

  def patches
    {:p1 => "https://gist.github.com/felixbuenemann/5790777/raw/cb5ea3b34617174e50fd3972792ec0944959de3c/zpython.patch"}
  end unless build.head?

  def install
    args = %W[
      --disable-gdbm
      --enable-zpython
    ]

    system "autoreconf"
    system "./configure", *args

    # Disable building docs due to exotic yodl dependency
    inreplace "Makefile", "subdir in Src Doc;", "subdir in Src;"

    system "make"
    (lib/"zpython/zsh").install "Src/Modules/zpython.so"
  end

  def test
    system "zsh -c 'MODULE_PATH=#{HOMEBREW_PREFIX}/lib/zpython zmodload zsh/zpython && zpython print'"
  end

  def caveats; <<-EOS.undent
    To use the zpython module in zsh you need to
    add the following line to your .zshrc:

    module_path=($module_path #{HOMEBREW_PREFIX}/lib/zpython)

    If you want to use this with powerline, make sure you set
    it early in .zshrc, before your prompt gets initialized.

    After reloading your shell you can test with:
      zmodload zsh/zpython && zpython 'print "hello world"'
    EOS
  end
end