Advertisement
cwchen

pygame

Aug 4th, 2014
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.75 KB | None | 0 0
  1. require 'formula'
  2.  
  3. # Todo: Install examples, run test
  4. # todo: What about sdl_gfx?
  5. # todo: depends_on :x11 ???
  6.  
  7. class Pygame < Formula
  8.   homepage 'http://pygame.org'
  9.   url 'http://pygame.org/ftp/pygame-1.9.1release.tar.gz'
  10.   sha1 'a45aeb0623e36ae7a1707b5f41ee6274f72ca4fa'
  11.   head 'https://bitbucket.org/pygame/pygame', :using => :hg
  12.  
  13.   depends_on :python
  14.   depends_on :python3 => :optional
  15.   depends_on 'sdl'
  16.   depends_on 'sdl_image'
  17.   depends_on 'sdl_mixer'
  18.   depends_on 'sdl_ttf'
  19.   depends_on 'homebrew/headonly/smpeg'
  20.   depends_on 'jpeg'
  21.   depends_on 'libpng'
  22.   depends_on 'portmidi'
  23.   depends_on 'numpy'
  24.  
  25.   if build.with? "python3"
  26.     depends_on 'numpy' => 'with-python3'
  27.   else
  28.     depends_on 'numpy'
  29.   end
  30.  
  31.   def patches
  32.     # Upstream https://bitbucket.org/pygame/pygame/issue/94/src-scale_mmx64c-cannot-be-compiled-with
  33.     # Will be fixed in next release.
  34.     if not build.head?
  35.       { :p0 => 'https://bitbucket.org/pygame/pygame/issue-attachment/94/pygame/pygame/20111022/94/patch-src_scale_mmx64.c.diff' }
  36.     end
  37.   end
  38.  
  39.   def install
  40.     # We provide a "Setup" file based on the "Setup.in" because the detection
  41.     # code in config.py does not know about the HOMEBREW_PREFIX, assumes SDL
  42.     # is built as a framework and cannot find the Frameworks inside of Xcode.
  43.     mv 'Setup.in', 'Setup'
  44.     sdl = Formula["sdl"].opt_prefix
  45.     sdl_ttf = Formula["sdl_ttf"].opt_prefix
  46.     sdl_image = Formula["sdl_image"].opt_prefix
  47.     sdl_mixer = Formula["sdl_mixer"].opt_prefix
  48.     smpeg = Formula["smpeg"].opt_prefix
  49.     png = Formula["libpng"].opt_prefix
  50.     jpeg = Formula["jpeg"].opt_prefix
  51.     portmidi = Formula["portmidi"].opt_prefix
  52.     inreplace 'Setup' do |s|
  53.       s.gsub!(/^SDL =.*$/, "SDL = -I#{sdl}/include/SDL -Ddarwin -lSDL")
  54.       s.gsub!(/^FONT =.*$/, "FONT = -I#{sdl_ttf}/include/SDL -lSDL_ttf")
  55.       s.gsub!(/^IMAGE =.*$/, "IMAGE = -I#{sdl_image}/include/SDL -lSDL_image")
  56.       s.gsub!(/^MIXER =.*$/, "MIXER = -I#{sdl_mixer}/include/SDL -lSDL_mixer")
  57.       s.gsub!(/^SMPEG =.*$/, "SMPEG = -I#{smpeg}/include/smpeg -lsmpeg")
  58.       s.gsub!(/^PNG =.*$/, "PNG = -lpng")
  59.       s.gsub!(/^JPEG =.*$/, "JPEG = -ljpeg")
  60.       s.gsub!(/^PORTMIDI =.*$/, "PORTMIDI = -I#{portmidi}/include/ -lportmidi")
  61.       s.gsub!(/^PORTTIME =.*$/, "PORTTIME = -I#{portmidi}/include/ -lportmidi")
  62.     end
  63.  
  64.     # Manually append what is the default for PyGame on the Mac
  65.     system "cat Setup_Darwin.in >> Setup"
  66.    
  67.     ENV.prepend_create_path "PYTHONPATH", lib+"python2.7/site-packages"
  68.     system "python", "setup.py", "install", "--prefix=#{prefix}"
  69.  
  70.     if build.with? "python3"
  71.       ENV.prepend_create_path "PYTHONPATH", lib+"python3.4/site-packages"
  72.       system "python3", "setup.py", "install", "--prefix=#{prefix}"
  73.     end
  74.   end
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement