aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/sip.rb
blob: 31bb36571b2d66f4e83d7822f98cdce0aeea2c7d (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
require 'formula'

class Sip < Formula
  homepage 'http://www.riverbankcomputing.co.uk/software/sip'
  url 'http://download.sf.net/project/pyqt/sip/sip-4.14.6/sip-4.14.6.tar.gz'
  sha1 'e9dfe98ab1418914c78fd3ac457a4e724aac9821'

  head 'http://www.riverbankcomputing.co.uk/hg/sip', :using => :hg

  depends_on :python => :recommended
  depends_on :python3 => :optional

  def install
    if build.head?
      # Link the Mercurial repository into the download directory so
      # buid.py can use it to figure out a version number.
      ln_s downloader.cached_location + '.hg', '.hg'
      system python, "build.py", "prepare"
    else
      sip_version = version
    end

    # The python block is run once for each python (2.x and 3.x if requested)
    python do
      # To have sip (for 2.x) and sip3 for python3, we rename the sip binary:
      inreplace "configure.py", 'os.path.join(opts.sipbindir, "sip")', "os.path.join(opts.sipbindir, 'sip3')" if python3

      # Set --destdir such that the python modules will be in the HOMEBREWPREFIX/lib/pythonX.Y/site-packages
      system python, "configure.py",
                              "--destdir=#{lib}/#{python.xy}/site-packages",
                              "--bindir=#{bin}",
                              "--incdir=#{include}",
                              "--sipdir=#{HOMEBREW_PREFIX}/share/sip#{python.if3then3}"
      system "make"
      if python3
        bin.mkdir unless bin.exist?
        bin.install 'sipgen/sip' => 'sip3'
      end
      system "make install"
      system "make clean"
    end

  end

  def caveats
    s = ''
    s += python.standard_caveats if python
    s += "The sip-dir for Python #{python.version.major}.x is #{HOMEBREW_PREFIX}/share/sip#{python.if3then3}."
    s
  end

end