[Pythonmac-SIG] why does the Mac installer hack the user's .bash_profile?

Ned Deily nad at acm.org
Fri Apr 8 00:37:26 CEST 2011


In article <64461.1302209314 at parc.com>, Bill Janssen <janssen at parc.com> 
wrote:
> I've got a Snow Leopard buildslave I'm trying to debug.  So I thought
> I'd try Python 2.7 on it.  Normally, I advise people to never try to
> install a different Python on a Mac, as it's too embedded in the OS to
> do safely, without a great deal of domain knowledge.  But here, I
> figured I could always wipe the disk and start over without too much
> loss.

I don't understand why you would say that.  The huge advantage of the 
Python framework installation layout on OS X is precisely that it 
*doesn't* get embedded into the OS and *does* allow multiple versions of 
Python to co-exist on a system far more easily and safely than with the 
traditional Python Unix layout.  With a very few exceptions, all of the 
files installed are under one root 
(Library/Frameworks/Python.framework/Versions/m.n/) with some auxiliary 
files under another (/Applications/Python m.n) and optionally some 
symlinks in /usr/local/bin, with *zero* overlap with any Apple-supplied 
files in OS X including the Apple-supplies Pythons.  If for some reason 
you do want to uninstall a framework build, it's a matter of two 'rm' 
commands and optionally removing some obvious symlinks in /usr/local/bin 
(which are not needed in the first place).  An official uninstall 
command would be nice to have and has been requested in the past (see 
http://bugs.python.org/issue7107).

If you are aware of problems where multiple framework installs cannot be 
installed safely, please open issues for them.
 
> So I ran the installer, and tried a few things, and it didn't solve my
> buildbot problems.  So I decided to go back to the original System
> python.  But now I find that the installer has put the 2.7 Python on my
> PATH?!?  It does this apparently by hacking ~/.bash_profile.  In there,
> there's a line saying
> 
>   The original version is saved in .bash_profile.pysave
> 
> a file which doesn't seem to exist.
> 
> So, why didn't I notice myself checking the checkbox to do this in the
> first place, and where is my original .bash_profile file?

The Python 2.7.1 installer welcome file, the text that is shown in the 
first installer screen, says this:

"This package will by default update your shell profile to ensure that 
this version of Python is on the search path of your shell. Please 
deselect the "Shell profile updater" package on the package 
customization screen if you want to avoid this modification.  
Double-click Update Shell Profile at any time to make 2.7.1 the default 
Python."

(Earlier installers had slightly different wordings.)

The command that does this is in /Applications/Python m.n/Update Shell 
Profile.command.  Normally, it should have saved your .bash_profile as 
~/.bash_profile.pysave, but, even if it didn't, the only modification it 
makes to your original .bash_profile is to append these (or similar) 
lines to the end of the file:

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

Hope that helps!

-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list