2010-04-17 18:50:15 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
# Python 2.7.x is available as a separate formula:
|
2011-03-19 19:40:09 +00:00
|
|
|
# $ 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-09-01 21:03:53 +00:00
|
|
|
class Distribute < Formula
|
2012-05-22 03:19:21 +00:00
|
|
|
url 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz'
|
|
|
|
md5 'ecd75ea629fee6d59d26f88c39b2d291'
|
2011-09-01 21:03:53 +00:00
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Python3 < Formula
|
2010-04-17 18:50:15 +00:00
|
|
|
homepage 'http://www.python.org/'
|
2012-04-12 02:19:59 +00:00
|
|
|
url 'http://python.org/ftp/python/3.2.3/Python-3.2.3.tar.bz2'
|
|
|
|
md5 'cea34079aeb2e21e7b60ee82a0ac286b'
|
2010-04-17 18:50:15 +00:00
|
|
|
|
2011-09-01 20:22:44 +00:00
|
|
|
depends_on 'pkg-config' => :build
|
|
|
|
|
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
|
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
# Skip binaries so modules will load; skip lib because it is mostly Python files
|
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
|
|
|
|
|
2010-04-17 18:50:15 +00:00
|
|
|
def install
|
2011-09-01 20:15:04 +00:00
|
|
|
args = ["--prefix=#{prefix}"]
|
2010-04-17 18:50:15 +00:00
|
|
|
|
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
|
|
|
|
2012-02-15 10:55:35 +00:00
|
|
|
if File.exist?( ENV['HOME']+'/.pydistutils.cfg' )
|
|
|
|
opoo 'Detected '+ENV['HOME']+'/.pydistutils.cfg which may cause trouble.
|
|
|
|
(See http://bugs.python.org/issue6138)'
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
2012-02-15 10:55:35 +00:00
|
|
|
# The "python3" executable is forgotten if the --framework option is used.
|
|
|
|
# Make sure homebrew symlinks it to `brew --prefix`/bin.
|
|
|
|
if ! (File.exist? "#{bin}/python3")
|
|
|
|
ln_s "#{bin}/python3.2", "#{bin}/python3"
|
|
|
|
end
|
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
# Post-install, fix up the site-packages and install-scripts folders
|
|
|
|
# so that user-installed Python software survives minor updates, such
|
2011-09-04 22:09:37 +00:00
|
|
|
# as going from 3.2.2 to 3.2.3.
|
2011-09-01 21:03:53 +00:00
|
|
|
|
|
|
|
# Remove the site-packages that Python created in its Cellar.
|
|
|
|
site_packages.rmtree
|
|
|
|
|
|
|
|
# Create a site-packages in the prefix.
|
2010-07-07 20:15:59 +00:00
|
|
|
prefix_site_packages.mkpath
|
2011-09-01 21:03:53 +00:00
|
|
|
|
|
|
|
# Symlink the prefix site-packages into the cellar.
|
|
|
|
ln_s prefix_site_packages, site_packages
|
|
|
|
|
|
|
|
# Tell distutils-based installers where to put scripts
|
|
|
|
scripts_folder.mkpath
|
2012-02-15 10:55:35 +00:00
|
|
|
(effective_lib/"python3.2/distutils/distutils.cfg").write <<-EOF.undent
|
2011-09-01 21:03:53 +00:00
|
|
|
[install]
|
|
|
|
install-scripts=#{scripts_folder}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Install distribute. The user can then do:
|
|
|
|
# $ easy_install pip
|
|
|
|
# $ pip install --upgrade distribute
|
|
|
|
# to get newer versions of distribute outside of Homebrew.
|
|
|
|
Distribute.new.brew do
|
2011-09-03 04:22:13 +00:00
|
|
|
system "#{bin}/python3.2", "setup.py", "install"
|
2011-09-01 21:03:53 +00:00
|
|
|
|
|
|
|
# Symlink to easy_install3 to match python3 command.
|
2012-02-15 10:55:35 +00:00
|
|
|
unless (scripts_folder/'easy_install3').exist?
|
2012-01-14 05:23:44 +00:00
|
|
|
ln_s "#{scripts_folder}/easy_install", "#{scripts_folder}/easy_install3"
|
|
|
|
end
|
2011-09-01 21:03:53 +00:00
|
|
|
end
|
2010-07-07 20:15:59 +00:00
|
|
|
end
|
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
def caveats
|
2012-02-15 10:55:35 +00:00
|
|
|
# Since right now, python 2.x is still the default (for homebrew), we
|
|
|
|
# suggest only a symlink to the framework Version 3.2 and not "Current".
|
2011-09-01 21:03:53 +00:00
|
|
|
framework_caveats = <<-EOS.undent
|
2011-03-19 19:40:09 +00:00
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
Framework Python was installed to:
|
|
|
|
#{prefix}/Frameworks/Python.framework
|
2010-07-07 20:15:59 +00:00
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
You may want to symlink this Framework to a standard OS X location,
|
|
|
|
such as:
|
2012-02-15 10:55:35 +00:00
|
|
|
mkdir -p ~/Library/Frameworks/Python.framework/Versions
|
|
|
|
ln -s "#{prefix}/Frameworks/Python.framework/Versions/3.2" ~/Library/Frameworks/Python.framework/Versions/3.2
|
2010-07-07 20:15:59 +00:00
|
|
|
EOS
|
2011-09-01 21:03:53 +00:00
|
|
|
|
2012-02-15 10:55:35 +00:00
|
|
|
# Tk warning only for 10.6 (not for Lion)
|
|
|
|
tk_caveats = <<-EOS.undent
|
|
|
|
Apple's Tcl/Tk is not recommended for use with Python on Mac OS X 10.6.
|
2011-09-01 21:03:53 +00:00
|
|
|
For more information see: http://www.python.org/download/mac/tcltk/
|
|
|
|
|
2012-02-15 10:55:35 +00:00
|
|
|
EOS
|
|
|
|
|
|
|
|
general_caveats = <<-EOS.undent
|
|
|
|
A "distutils.cfg" has been written, specifing the install-scripts folder as:
|
2011-09-01 21:03:53 +00:00
|
|
|
#{scripts_folder}
|
|
|
|
|
2012-02-15 10:55:35 +00:00
|
|
|
If you install Python packages via "python3 setup.py install", easy_install3,
|
|
|
|
pip-3.2, any provided scripts will go into the install-scripts folder above, so
|
|
|
|
you may want to add it to your PATH.
|
2011-09-01 21:03:53 +00:00
|
|
|
|
|
|
|
Distribute has been installed, so easy_install is available.
|
|
|
|
To update distribute itself outside of Homebrew:
|
2012-02-15 10:55:35 +00:00
|
|
|
#{scripts_folder}/easy_install3 pip
|
|
|
|
#{scripts_folder}/pip-3.2 install --upgrade distribute
|
2011-09-01 21:03:53 +00:00
|
|
|
|
|
|
|
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
|
|
|
|
EOS
|
|
|
|
|
|
|
|
s = general_caveats
|
2012-02-15 10:55:35 +00:00
|
|
|
s += tk_caveats if not MacOS.lion?
|
2011-09-01 21:03:53 +00:00
|
|
|
s += framework_caveats if as_framework?
|
|
|
|
return s
|
|
|
|
end
|
|
|
|
|
|
|
|
# lib folder,taking into account whether we are a Framework build or not
|
|
|
|
def effective_lib
|
|
|
|
# If we're installed or installing as a Framework, then use that location.
|
|
|
|
return prefix+"Frameworks/Python.framework/Versions/3.2/lib" if as_framework?
|
|
|
|
# Otherwise use just 'lib'
|
|
|
|
return lib
|
|
|
|
end
|
|
|
|
|
2012-02-26 01:12:54 +00:00
|
|
|
# include folder,taking into account whether we are a Framework build or not
|
|
|
|
def effective_include
|
|
|
|
# If we're installed or installing as a Framework, then use that location.
|
|
|
|
return prefix+"Frameworks/Python.framework/Versions/3.2/include" if as_framework?
|
|
|
|
# Otherwise use just 'include'
|
|
|
|
return include
|
|
|
|
end
|
|
|
|
|
2011-09-01 21:03:53 +00:00
|
|
|
# The Cellar location of site-packages
|
|
|
|
def site_packages
|
|
|
|
effective_lib+"python3.2/site-packages"
|
|
|
|
end
|
|
|
|
|
|
|
|
# The HOMEBREW_PREFIX location of site-packages
|
|
|
|
def prefix_site_packages
|
|
|
|
HOMEBREW_PREFIX+"lib/python3.2/site-packages"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Where distribute will install executable scripts
|
|
|
|
def scripts_folder
|
|
|
|
HOMEBREW_PREFIX+"share/python3"
|
2010-04-17 18:50:15 +00:00
|
|
|
end
|
2012-02-15 10:55:35 +00:00
|
|
|
|
|
|
|
# See: https://github.com/mxcl/homebrew/pull/10487
|
|
|
|
def test
|
|
|
|
`#{bin}/python3 -c 'from decimal import Decimal; print(Decimal(4) / Decimal(2))'`.chomp == '2'
|
|
|
|
end
|
2010-04-17 18:50:15 +00:00
|
|
|
end
|