homebrew / Library / Formula / sip.rb

require 'formula'

# Unless Riverbank policy changes in the future or the Mercurial archive
# becomes unavailable, *do not use* the SIP download URL from the Riverbank
# website. This URL will break as soon as a new version of SIP is released
# which causes panic and terror to flood the Homebrew issue tracker.

class Sip < Formula
  homepage ''
  url ''
  sha1 '672f0bd9c13860979ab2a7753b2bf91475a4deeb'

  head '', :using => :hg

  def patches

  def install
    if ARGV.build_head?
      # Set fallback version to the same value it would have without the patch
      # and link the Mercurial repository into the download directory so
      # can use it to figure out a version number.
      sip_version = "0.1.0"
      ln_s downloader.cached_location + '.hg', '.hg'
      sip_version = version
    inreplace '', /@SIP_VERSION@/, (sip_version.gsub '.', ',')

    system "python", "", "prepare"
    # Set --destdir such that the python modules will be in the HOMEBREWPREFIX/lib/pythonX.Y/site-packages
    system "python", "",
    system "make install"

  def caveats; <<-EOS.undent
    For non-homebrew Python, you need to amend your PYTHONPATH like so:
      export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH

  def which_python
    "python" + `python -c 'import sys;print(sys.version[:3])'`.strip

Patch to allow the SIP script to generate a reasonable version number
for installing from a Mercurial snapshot without the .hg directory from the
Mercurial repository. The install code hooks on to the @SIP_VERSION@ tag and
inserts a real version tuple

diff --git a/ b/
index 927d7f1..fdf13a3 100755
--- a/
+++ b/
@@ -179,7 +179,7 @@ def _get_release():
         changelog = None
         name = os.path.basename(_RootDir)
-        release_suffix = "-unknown"
+        release_suffix = ""
         version = None
         parts = name.split('-')
@@ -192,7 +192,7 @@ def _get_release():
     # Format the results.
     if version is None:
-        version = (0, 1, 0)
+        version = (@SIP_VERSION@)
     major, minor, micro = version

Patch to remove the seemingly unnecessary framework build requirement
diff --git a/ b/
index 57e8911..1af6152 100644
--- a/
+++ b/
@@ -1434,8 +1434,8 @@ class ModuleMakefile(Makefile):
             # 'real_prefix' exists if virtualenv is being used.
             dl = getattr(sys, 'real_prefix', sys.exec_prefix).split(os.sep)
-            if "Python.framework" not in dl:
-                error("SIP requires Python to be built as a framework")
+            # if "Python.framework" not in dl:
+                # error("SIP requires Python to be built as a framework")
             self.LFLAGS.append("-undefined dynamic_lookup")