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

Ronald Oussoren ronaldoussoren at mac.com
Mon Apr 11 07:36:26 CEST 2011

On 7 Apr, 2011, at 22:48, Bill Janssen 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.
> 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?!?

That's correct, there is an option to disable this behavior. This option is on by default because we had a lot of users that installed Python and then didn't know how to start python because we don't install files in /usr/bin.

>  It does this apparently by hacking ~/.bash_profile.  In there,
> there's a line saying
>  The original version is saved in .bash_profile.pysave

That's odd, the scriptlet that does the work says ($PR is the path to the profile):

if [ -f "${PR}" ]; then
        cp -fp "${PR}" "${PR}.pysave"
echo "" >> "${PR}"
echo "# Setting PATH for Python ${PYVER}" >> "${PR}"
echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}"
echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}"
echo 'export PATH' >> "${PR}"

> 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 checkbox is on by default.   Did you have a .bash_profile at all? The scriptlet I quoted earlier indicates that the backup is created when the source file exists. 


More information about the Pythonmac-SIG mailing list