aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/python3.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2011-09-01 14:03:53 -0700
committerAdam Vandenberg2011-09-01 15:04:59 -0700
commitf6a23ed6a600f524284bab7197596d6524ec1f31 (patch)
tree23f65a247c0dec7c0907f0673f1f86fefeaf14f7 /Library/Formula/python3.rb
parent9b4f9570991160b38c992758e13dd2dfdbdbb0f9 (diff)
downloadhomebrew-f6a23ed6a600f524284bab7197596d6524ec1f31.tar.bz2
Python 3: add distribute
Based substantially on a patch by @joshuajabbour See: https://github.com/mxcl/homebrew/pull/5276
Diffstat (limited to 'Library/Formula/python3.rb')
-rw-r--r--Library/Formula/python3.rb107
1 files changed, 90 insertions, 17 deletions
diff --git a/Library/Formula/python3.rb b/Library/Formula/python3.rb
index df8ac1a7e..9bf89c8b4 100644
--- a/Library/Formula/python3.rb
+++ b/Library/Formula/python3.rb
@@ -1,7 +1,6 @@
require 'formula'
-# This formula is for Python version 3.2.
-# Python 2.7.1 is available as a separate formula:
+# Python 2.7.x is available as a separate formula:
# $ brew install python
# Was a Framework build requested?
@@ -12,6 +11,11 @@ def as_framework?
(self.installed? and File.exists? prefix+"Frameworks/Python.framework") or build_framework?
end
+class Distribute < Formula
+ url 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.21.tar.gz'
+ md5 'c8cfcfd42ec9ab900fb3960a3308eef2'
+end
+
class Python3 < Formula
url 'http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.bz2'
homepage 'http://www.python.org/'
@@ -31,6 +35,7 @@ class Python3 < Formula
]
end
+ # Skip binaries so modules will load; skip lib because it is mostly Python files
skip_clean ['bin', 'lib']
# The Cellar location of site-packages
@@ -45,12 +50,6 @@ class Python3 < Formula
end
end
- # The HOMEBREW_PREFIX location of site-packages
- # We write a .pth file in the Cellar site-packages to here
- def prefix_site_packages
- HOMEBREW_PREFIX+"lib/python3.2/site-packages"
- end
-
def install
args = ["--prefix=#{prefix}"]
@@ -69,20 +68,94 @@ class Python3 < Formula
ENV.j1 # Installs must be serialized
system "make install"
- # Add the Homebrew prefix path to site-packages via a .pth
+ # Post-install, fix up the site-packages and install-scripts folders
+ # so that user-installed Python software survives minor updates, such
+ # as going from 3.2.1 to 3.2.2.
+
+ # Remove the site-packages that Python created in its Cellar.
+ site_packages.rmtree
+
+ # Create a site-packages in the prefix.
prefix_site_packages.mkpath
- (site_packages+"homebrew.pth").write prefix_site_packages
+
+ # 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
+ (effective_lib+"python3.2/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 do
+ system "#{bin}/python3", "setup.py", "install"
+
+ # Symlink to easy_install3 to match python3 command.
+ ln_s "#{scripts_folder}/easy_install", "#{scripts_folder}/easy_install3"
+ end
end
- 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/
+ def caveats
+ framework_caveats = <<-EOS.undent
- The site-packages folder for this Python is:
- #{site_packages}
+ Framework Python was installed to:
+ #{prefix}/Frameworks/Python.framework
- We've added a "homebrew.pth" file to also include:
- #{prefix_site_packages}
+ You may want to symlink this Framework to a standard OS X location,
+ such as:
+ mkdir ~/Frameworks
+ ln -s "#{prefix}/Frameworks/Python.framework" ~/Frameworks
EOS
+
+ general_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/
+
+ A "distutils.cfg" has been written, specifing the install-scripts folder as:
+ #{scripts_folder}
+
+ 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.
+
+ Distribute has been installed, so easy_install is available.
+ To update distribute itself outside of Homebrew:
+ #{scripts_folder}/easy_install pip
+ #{scripts_folder}/pip install --upgrade distribute
+
+ See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
+ EOS
+
+ s = general_caveats
+ 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
+
+ # 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"
end
end