2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-07-30 01:25:18 +00:00
|
|
|
|
2010-06-30 00:24:25 +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 17:32:29 +00:00
|
|
|
class Distribute < Formula
|
|
|
|
url 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.21.tar.gz'
|
|
|
|
md5 'c8cfcfd42ec9ab900fb3960a3308eef2'
|
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Python < Formula
|
2011-06-12 18:35:54 +00:00
|
|
|
url 'http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2'
|
2009-10-02 04:00:15 +00:00
|
|
|
homepage 'http://www.python.org/'
|
2011-06-12 18:35:54 +00:00
|
|
|
md5 'ba7b2f11ffdbf195ee0d111b9455a5bd'
|
2009-07-30 01:25:18 +00:00
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
depends_on 'readline' => :optional # Prefer over OS X's libedit
|
|
|
|
depends_on 'sqlite' => :optional # Prefer over OS X's older version
|
2010-07-07 20:15:52 +00:00
|
|
|
depends_on 'gdbm' => :optional
|
2009-12-13 18:25:07 +00:00
|
|
|
|
2009-10-02 04:00:15 +00:00
|
|
|
def options
|
|
|
|
[
|
|
|
|
["--framework", "Do a 'Framework' build instead of a UNIX-style build."],
|
2010-06-30 00:24:25 +00:00
|
|
|
["--universal", "Build for both 32 & 64 bit Intel."],
|
2011-03-05 20:06:52 +00:00
|
|
|
["--static", "Build static libraries."],
|
|
|
|
["--no-poll", "Remove HAVE_POLL.* options from build."]
|
2009-10-02 04:00:15 +00:00
|
|
|
]
|
|
|
|
end
|
2009-09-17 20:56:49 +00:00
|
|
|
|
2010-06-30 00:24:25 +00:00
|
|
|
# Skip binaries so modules will load; skip lib because it is mostly Python files
|
|
|
|
skip_clean ['bin', 'lib']
|
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
def install
|
2010-06-30 00:24:25 +00:00
|
|
|
if build_framework? and ARGV.include? "--static"
|
|
|
|
onoe "Cannot specify both framework and static."
|
|
|
|
exit 99
|
|
|
|
end
|
|
|
|
|
2009-10-02 04:00:15 +00:00
|
|
|
args = ["--prefix=#{prefix}"]
|
2010-06-30 00:24:25 +00:00
|
|
|
|
2011-04-21 16:42:27 +00:00
|
|
|
if ARGV.build_universal?
|
2010-06-30 00:24:25 +00:00
|
|
|
args << "--enable-universalsdk=/" << "--with-universal-archs=intel"
|
2010-03-12 18:20:11 +00:00
|
|
|
end
|
2010-06-30 00:24:25 +00:00
|
|
|
|
|
|
|
if build_framework?
|
|
|
|
args << "--enable-framework=#{prefix}/Frameworks"
|
|
|
|
else
|
|
|
|
args << "--enable-shared" unless ARGV.include? '--static'
|
|
|
|
end
|
|
|
|
|
2010-09-22 06:15:33 +00:00
|
|
|
# allow sqlite3 module to load extensions
|
|
|
|
inreplace "setup.py",
|
2011-03-19 23:44:46 +00:00
|
|
|
'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', ''
|
2010-09-22 06:15:33 +00:00
|
|
|
|
2009-10-02 04:00:15 +00:00
|
|
|
system "./configure", *args
|
2011-03-05 20:06:52 +00:00
|
|
|
|
|
|
|
if ARGV.include? '--no-poll'
|
|
|
|
inreplace 'pyconfig.h', /.*?(HAVE_POLL[_A-Z]*).*/, '#undef \1'
|
|
|
|
end
|
|
|
|
|
2009-07-30 01:25:18 +00:00
|
|
|
system "make"
|
2010-07-07 20:15:52 +00:00
|
|
|
ENV.j1 # Installs must be serialized
|
2009-07-30 01:25:18 +00:00
|
|
|
system "make install"
|
2010-06-30 00:24:25 +00:00
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
# Post-install, fix up the site-packages and install-scripts folders
|
|
|
|
# so that user-installed Python software survives minor updates, such
|
|
|
|
# as going from 2.7.0 to 2.7.1.
|
|
|
|
|
|
|
|
# Remove the site-packages that Python created in its Cellar.
|
|
|
|
site_packages.rmtree
|
|
|
|
|
|
|
|
# Create a site-packages in the prefix.
|
2010-06-30 00:24:25 +00:00
|
|
|
prefix_site_packages.mkpath
|
2011-03-19 23:44:46 +00:00
|
|
|
|
|
|
|
# Symlink the prefix site-packages into the cellar.
|
|
|
|
ln_s prefix_site_packages, site_packages
|
|
|
|
|
2011-06-29 23:02:17 +00:00
|
|
|
# This is a fix for better interoperability with pyqt.
|
|
|
|
# See Issue #6176.
|
|
|
|
if not as_framework?
|
|
|
|
(bin+"pythonw").make_link bin+"python"
|
|
|
|
(bin+"pythonw2.7").make_link bin+"python2.7"
|
|
|
|
end
|
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
# Tell distutils-based installers where to put scripts
|
|
|
|
scripts_folder.mkpath
|
|
|
|
(effective_lib+"python2.7/distutils/distutils.cfg").write <<-EOF.undent
|
|
|
|
[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 { system "#{bin}/python", "setup.py", "install" }
|
2010-06-30 00:24:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def caveats
|
|
|
|
framework_caveats = <<-EOS.undent
|
2011-03-19 23:44:46 +00:00
|
|
|
|
2010-06-30 00:24:25 +00:00
|
|
|
Framework Python was installed to:
|
|
|
|
#{prefix}/Frameworks/Python.framework
|
|
|
|
|
|
|
|
You may want to symlink this Framework to a standard OS X location,
|
|
|
|
such as:
|
2011-04-04 23:56:47 +00:00
|
|
|
mkdir ~/Frameworks
|
|
|
|
ln -s "#{prefix}/Frameworks/Python.framework" ~/Frameworks
|
2010-06-30 00:24:25 +00:00
|
|
|
EOS
|
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
general_caveats = <<-EOS.undent
|
|
|
|
A "distutils.cfg" has been written, specifing the install-scripts folder as:
|
|
|
|
#{scripts_folder}
|
2010-06-30 00:24:25 +00:00
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
If you install Python packages via "python setup.py install", easy_install, pip,
|
|
|
|
any provided scripts will go into the install-scripts folder above, so you may
|
|
|
|
want to add it to your PATH.
|
2010-06-30 00:24:25 +00:00
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
Distribute has been installed, so easy_install is available.
|
|
|
|
To update distribute itself outside of Homebrew:
|
2011-04-04 23:56:47 +00:00
|
|
|
#{scripts_folder}/easy_install pip
|
|
|
|
#{scripts_folder}/pip install --upgrade distribute
|
2010-06-30 00:24:25 +00:00
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
|
2010-06-30 00:24:25 +00:00
|
|
|
EOS
|
|
|
|
|
2011-03-19 23:44:46 +00:00
|
|
|
s = general_caveats
|
|
|
|
s += framework_caveats if as_framework?
|
2010-06-30 00:24:25 +00:00
|
|
|
return s
|
2009-07-30 01:25:18 +00:00
|
|
|
end
|
2011-03-19 23:44:46 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Path helpers
|
|
|
|
|
|
|
|
def effective_lib
|
|
|
|
# If we're installed or installing as a Framework, then use that location.
|
|
|
|
return prefix+"Frameworks/Python.framework/Versions/2.7/lib" if as_framework?
|
|
|
|
# Otherwise use just 'lib'
|
|
|
|
return lib
|
|
|
|
end
|
|
|
|
|
|
|
|
# The Cellar location of site-packages
|
|
|
|
def site_packages
|
2011-04-04 23:56:47 +00:00
|
|
|
effective_lib+"python2.7/site-packages"
|
2011-03-19 23:44:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# The HOMEBREW_PREFIX location of site-packages
|
|
|
|
def prefix_site_packages
|
|
|
|
HOMEBREW_PREFIX+"lib/python2.7/site-packages"
|
|
|
|
end
|
|
|
|
|
|
|
|
def scripts_folder
|
|
|
|
HOMEBREW_PREFIX+"share/python"
|
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
end
|