forked from codedreality/homebrew-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pygame.rb
64 lines (57 loc) · 2.4 KB
/
pygame.rb
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
require 'formula'
# Todo: Install examples, run test
# todo: What about sdl_gfx?
# todo: depends_on :x11 ???
class Pygame < Formula
homepage 'http://pygame.org'
url 'http://pygame.org/ftp/pygame-1.9.1release.tar.gz'
sha1 'a45aeb0623e36ae7a1707b5f41ee6274f72ca4fa'
head 'https://bitbucket.org/pygame/pygame', :using => :hg
depends_on :python
depends_on 'sdl'
depends_on 'sdl_image'
depends_on 'sdl_mixer'
depends_on 'sdl_ttf'
depends_on 'homebrew/headonly/smpeg'
depends_on 'jpeg'
depends_on 'libpng'
depends_on 'portmidi'
depends_on 'numpy'
# Upstream https://bitbucket.org/pygame/pygame/issue/94/src-scale_mmx64c-cannot-be-compiled-with
# Will be fixed in next release.
stable do
patch :p0 do
url "https://bitbucket.org/pygame/pygame/issue-attachment/94/pygame/pygame/20111022/94/patch-src_scale_mmx64.c.diff"
sha1 "f189dfc2d684344a4ab756d76df26c05175b1e7e"
end
end
def install
# We provide a "Setup" file based on the "Setup.in" because the detection
# code in config.py does not know about the HOMEBREW_PREFIX, assumes SDL
# is built as a framework and cannot find the Frameworks inside of Xcode.
mv 'Setup.in', 'Setup'
sdl = Formula["sdl"].opt_prefix
sdl_ttf = Formula["sdl_ttf"].opt_prefix
sdl_image = Formula["sdl_image"].opt_prefix
sdl_mixer = Formula["sdl_mixer"].opt_prefix
smpeg = Formula["smpeg"].opt_prefix
png = Formula["libpng"].opt_prefix
jpeg = Formula["jpeg"].opt_prefix
portmidi = Formula["portmidi"].opt_prefix
inreplace 'Setup' do |s|
s.gsub!(/^SDL =.*$/, "SDL = -I#{sdl}/include/SDL -Ddarwin -lSDL")
s.gsub!(/^FONT =.*$/, "FONT = -I#{sdl_ttf}/include/SDL -lSDL_ttf")
s.gsub!(/^IMAGE =.*$/, "IMAGE = -I#{sdl_image}/include/SDL -lSDL_image")
s.gsub!(/^MIXER =.*$/, "MIXER = -I#{sdl_mixer}/include/SDL -lSDL_mixer")
s.gsub!(/^SMPEG =.*$/, "SMPEG = -I#{smpeg}/include/smpeg -lsmpeg")
s.gsub!(/^PNG =.*$/, "PNG = -lpng")
s.gsub!(/^JPEG =.*$/, "JPEG = -ljpeg")
s.gsub!(/^PORTMIDI =.*$/, "PORTMIDI = -I#{portmidi}/include/ -lportmidi")
s.gsub!(/^PORTTIME =.*$/, "PORTTIME = -I#{portmidi}/include/ -lportmidi")
end
# Manually append what is the default for PyGame on the Mac
system "cat Setup_Darwin.in >> Setup"
ENV.prepend_create_path "PYTHONPATH", lib+"python2.7/site-packages"
system "python", "setup.py", "install", "--prefix=#{prefix}"
end
end