2010-04-17 18:50:15 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-19 19:40:09 +00:00
|
|
|
# This formula is for Python version 3.2.
|
|
|
|
# Python 2.7.1 is available as a separate formula:
|
|
|
|
# $ brew install python
|
2010-07-07 20:15:59 +00:00
|
|
|
|
|
|
|
# Was a Framework build requested?
|
|
|
|
def build_framework?; ARGV.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
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Python3 < Formula
|
2011-02-21 23:31:22 +00:00
|
|
|
url 'http://www.python.org/ftp/python/3.2/Python-3.2.tar.bz2'
|
2010-04-17 18:50:15 +00:00
|
|
|
homepage 'http://www.python.org/'
|
2011-02-21 23:31:22 +00:00
|
|
|
md5 '92e94b5b6652b96349d6362b8337811d'
|
2010-04-17 18:50:15 +00:00
|
|
|
|
2010-07-07 20:15:59 +00:00
|
|
|
depends_on 'readline' => :optional # Prefer over OS X's libedit
|
|
|
|
depends_on 'sqlite' => :optional # Prefer over OS X's older version
|
|
|
|
depends_on 'gdbm' => :optional
|
2010-04-17 18:50:15 +00:00
|
|
|
|
|
|
|
def options
|
|
|
|
[
|
|
|
|
["--framework", "Do a 'Framework' build instead of a UNIX-style build."],
|
2010-07-07 20:15:59 +00:00
|
|
|
["--universal", "Build for both 32 & 64 bit Intel."],
|
|
|
|
["--static", "Build static libraries."]
|
2010-04-17 18:50:15 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2010-07-07 20:15:59 +00:00
|
|
|
skip_clean ['bin', 'lib']
|
|
|
|
|
2011-03-19 19:40:09 +00:00
|
|
|
# The Cellar location of site-packages
|
|
|
|
# This location is different for Framework builds
|
2010-07-07 20:15:59 +00:00
|
|
|
def site_packages
|
|
|
|
if as_framework?
|
|
|
|
# If we're installed or installing as a Framework, then use that location.
|
2011-02-21 23:31:22 +00:00
|
|
|
return prefix+"Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages"
|
2010-07-07 20:15:59 +00:00
|
|
|
else
|
|
|
|
# Otherwise, use just the lib path.
|
2011-02-21 23:31:22 +00:00
|
|
|
return lib+"python3.2/site-packages"
|
2010-07-07 20:15:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-19 19:40:09 +00:00
|
|
|
# The HOMEBREW_PREFIX location of site-packages
|
|
|
|
# We write a .pth file in the Cellar site-packages to here
|
2010-07-07 20:15:59 +00:00
|
|
|
def prefix_site_packages
|
2011-02-21 23:31:22 +00:00
|
|
|
HOMEBREW_PREFIX+"lib/python3.2/site-packages"
|
2010-04-17 18:50:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
2011-03-19 19:40:09 +00:00
|
|
|
# --with-computed-gotos requires addressable labels in C.
|
|
|
|
# Both gcc and LLVM support this, so switch it on.
|
2010-04-17 18:50:15 +00:00
|
|
|
args = ["--prefix=#{prefix}", "--with-computed-gotos"]
|
|
|
|
|
2011-04-21 16:42:27 +00:00
|
|
|
if ARGV.build_universal?
|
2010-07-07 20:15:59 +00:00
|
|
|
args << "--enable-universalsdk=/" << "--with-universal-archs=intel"
|
|
|
|
end
|
|
|
|
|
|
|
|
if build_framework?
|
|
|
|
args << "--enable-framework=#{prefix}/Frameworks"
|
|
|
|
else
|
|
|
|
args << "--enable-shared" unless ARGV.include? '--static'
|
2010-04-17 18:50:15 +00:00
|
|
|
end
|
2010-07-07 20:15:59 +00:00
|
|
|
|
2010-04-17 18:50:15 +00:00
|
|
|
system "./configure", *args
|
|
|
|
system "make"
|
2010-07-07 20:15:59 +00:00
|
|
|
ENV.j1 # Installs must be serialized
|
2010-04-17 18:50:15 +00:00
|
|
|
system "make install"
|
2010-07-07 20:15:59 +00:00
|
|
|
|
|
|
|
# Add the Homebrew prefix path to site-packages via a .pth
|
|
|
|
prefix_site_packages.mkpath
|
|
|
|
(site_packages+"homebrew.pth").write prefix_site_packages
|
|
|
|
end
|
|
|
|
|
2011-03-19 19:40:09 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
Apple's Tcl/Tk is not recommended for use with 64-bit Python.
|
|
|
|
For more information see: http://www.python.org/download/mac/tcltk/
|
|
|
|
|
|
|
|
The site-packages folder for this Python is:
|
|
|
|
#{site_packages}
|
2010-07-07 20:15:59 +00:00
|
|
|
|
2011-03-19 19:40:09 +00:00
|
|
|
We've added a "homebrew.pth" file to also include:
|
|
|
|
#{prefix_site_packages}
|
2010-07-07 20:15:59 +00:00
|
|
|
EOS
|
2010-04-17 18:50:15 +00:00
|
|
|
end
|
|
|
|
end
|