-
Notifications
You must be signed in to change notification settings - Fork 0
Homebrew and Python
Note: This page describes Homebrew's Python formula as it will be after this Issue is resolved: https://github.com/mxcl/homebrew/issues/4226
work-in-progress
- site-packages
- scripts folder
- distutils.cfg
Homebrew provides a formula for Python 2.7.1. This is somewhat counter to the "no system duplicates" policy, but Leopard comes with 2.5.x, Snow Leopard comes with 2.6.x, and it is useful to be able to get the latest Python 2 in an easy way.
Assuming a standard Homebrew install, the Prefix will be /usr/local
and the Cellar will be /usr/local/Cellar
.
Homebrew installs Python to the Cellar, using the standard ./configure --prefix=#{prefix}
.
This sets up:
- the "site-packages" folder as
/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages
. - the "install-scripts" folder as
/usr/local/Cellar/python/2.7.1/bin
.
If site-packages
lives in Python's Cellar, then user installed packages will be wiped between Python updates. Same for install-scripts
, with the added problem that users have to manually add Python's cellar bin folder to the path.
Homebrew performs two actions on install to address these issues.
First, the Cellar site-packages folder is removed, and a symlink to /usr/local/lib/python2.7/site-packages
in the Prefix is created. This will allow site-packages to persist between Python updates, as Homebrew has special handling for some languages that use lib
for user-installable libraries.
Second, a distutils.cfg file is written ( http://docs.python.org/install/index.html#distutils-configuration-files ) to set the install-scripts
folder to /usr/local/share/python
. Users can add /usr/local/share/python
to the PATH to pick up installed scripts.
These changes allow Homebrew to play along with distutils, which is the basis for distribute and pip as well.
Because of these changes, the separate distribute
and pip
formulae are no longer needed, and have been removed.
Assuming the Python brew installs Distribute, does this work?
- distribute provides easy_install in
/usr/local/share/python
. -
easy_install pip
to get pip -
pip install --upgrade distribute
to update distribute