forked from lotia/homebrew-versions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
python31.rb
76 lines (61 loc) · 2.16 KB
/
python31.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
65
66
67
68
69
70
71
72
73
74
75
76
require 'formula'
class Python31 < Formula
homepage 'http://www.python.org/'
url 'http://www.python.org/ftp/python/3.1.5/Python-3.1.5.tar.bz2'
sha1 '48f97250c0482d9672938f5781e66dbd19cd4374'
option :universal
option 'framework', 'Do a Framework build instead of a UNIX-style build'
option 'static', 'Build static libraries'
depends_on 'readline' => :recommended
depends_on 'sqlite' => :recommended
depends_on 'gdbm' => :recommended
skip_clean ['bin', 'lib']
# Was a Framework build requested?
def build_framework?; build.include? 'framework'; end
# Are we installed or installing as a Framework?
def as_framework?
(self.installed? and File.exists? prefix+"Frameworks/Python.framework") or build_framework?
end
def site_packages
# The Cellar location of site-packages
if as_framework?
# If we're installed or installing as a Framework, then use that location.
return prefix+"Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages"
else
# Otherwise, use just the lib path.
return lib+"python3.1/site-packages"
end
end
def prefix_site_packages
# The HOMEBREW_PREFIX location of site-packages
HOMEBREW_PREFIX+"lib/python3.1/site-packages"
end
def install
# --with-computed-gotos requires addressable labels in C;
# both gcc and LLVM support this, so switch it on.
args = ["--prefix=#{prefix}", "--with-computed-gotos"]
if build.universal?
args << "--enable-universalsdk=/" << "--with-universal-archs=intel"
end
if build_framework?
args << "--enable-framework=#{prefix}/Frameworks"
else
args << "--enable-shared" unless build.include? 'static'
end
system "./configure", *args
system "make"
ENV.j1 # Installs must be serialized
system "make install"
# Add the Homebrew prefix path to site-packages via a .pth
prefix_site_packages.mkpath
(site_packages+"homebrew.pth").write prefix_site_packages
end
def caveats
<<-EOS.undent
The site-packages folder for this Python is:
#{site_packages}
We've added a "homebrew.pth" file to also include:
#{prefix_site_packages}
EOS
end
end