11require 'formula'
22
3+ class Distribute < Formula
4+ url 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.34.tar.gz'
5+ sha1 'b6f9cfbaf3e63833b71009812a613be13e68f5de'
6+ end
7+
8+ class Pip < Formula
9+ url 'http://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz'
10+ sha1 '35db84983ef3f66a8a161d320e61d192afc233d9'
11+ end
12+
313class Python < Formula
414 homepage 'http://www.python.org'
515 url 'http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2'
616 sha1 '842c4e2aff3f016feea3c6e992c7fa96e49c9aa0'
7- version '2.7.3-boxen1 '
17+ version '2.7.3-boxen2 '
818
919 option :universal
1020 option 'quicktest' , 'Run `make quicktest` after the build'
@@ -41,7 +51,7 @@ def site_packages
4151 HOMEBREW_PREFIX /"lib/python2.7/site-packages"
4252 end
4353
44- # Where distribute/pip will later install executable scripts.
54+ # Where distribute/pip will install executable scripts.
4555 def scripts_folder
4656 HOMEBREW_PREFIX /"share/python"
4757 end
@@ -99,12 +109,8 @@ def install
99109 # so that user-installed Python software survives minor updates, such
100110 # as going from 2.7.0 to 2.7.1:
101111
102- # Remove the site-packages that Python created in its Cellar.
103- site_packages_cellar . rmtree
104- # Create a site-packages in HOMEBREW_PREFIX/lib/python/site-packages
105- site_packages . mkpath
106- # Symlink the prefix site-packages into the cellar.
107- ln_s site_packages , site_packages_cellar
112+ # Symlink the cellar into the prefix site-packages.
113+ ln_s site_packages_cellar , site_packages
108114
109115 # Teach python not to use things from /System
110116 # and tell it about the correct site-package dir because we moved it
@@ -116,7 +122,7 @@ def install
116122 import sys
117123 import site
118124
119- # Only do fix 1 and 2, if the currently run python is a brewed one.
125+ # Only fix if the currently run python is a brewed one.
120126 if sys.executable.startswith('#{ HOMEBREW_PREFIX } '):
121127 # Fix 1)
122128 # A setuptools.pth and/or easy-install.pth sitting either in
@@ -129,16 +135,21 @@ def install
129135 # See: https://github.com/mxcl/homebrew/issues/14712
130136 sys.path = [ p for p in sys.path if not p.startswith('/System') ]
131137
132- # Fix 2)
133- # Remove brewed Python's hard-coded site-packages
134- sys.path.remove('#{ site_packages_cellar } ')
135-
136- # Fix 3)
138+ # Fix 2)
137139 # For all Pythons: Tell about homebrew's site-packages location.
138140 # This is needed for Python to parse *.pth files.
139141 site.addsitedir('#{ site_packages } ')
140142 EOF
141143
144+ # Install distribute and pip
145+ # It's important to have these installers in our bin, because some users
146+ # forget to put #{script_folder} in PATH, then easy_install'ing
147+ # into /Library/Python/X.Y/site-packages with /usr/bin/easy_install.
148+ mkdir_p scripts_folder unless scripts_folder . exist?
149+ setup_args = [ "-s" , "setup.py" , "--no-user-cfg" , "install" , "--force" , "--verbose" , "--install-lib=#{ site_packages_cellar } " , "--install-scripts=#{ bin } " ]
150+ Distribute . new . brew { system "#{ bin } /python" , *setup_args }
151+ Pip . new . brew { system "#{ bin } /python" , *setup_args }
152+
142153 # Tell distutils-based installers where to put scripts and python modules
143154 ( prefix /"Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/distutils.cfg" ) . write <<-EOF . undent
144155 [install]
0 commit comments