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

Ronald Oussoren ronaldoussoren at mac.com
Mon Apr 11 07:44:42 CEST 2011


On 8 Apr, 2011, at 0:56, Russell E. Owen wrote:

> 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.
>> 
>> 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?
> 
> I'm surprised you can't find it. I've always had it saved on some 
> obvious place. But I agree that hacking the file is ugly -- it least it 
> could ask.

Feel free to file a bug and attach a patch that does this. 

> 
> In any case you can revert by just deleting the extra lines.
> 
> Other gripes about the installer:
> - It names the version explicitly instead of using the Current symlink 
> (/Libraries/Packages/Python.Package/Versions/Current).

That's intentional, if you install 2.6 with the default settings and 2.7 with the 'update shell profile' section disabled you'd want python 2.6 to be on $PATH while 2.7 shouldn't be. This cannot be done without hardcoding version.

> - It hacks the file even if doesn't need to (e.g. if Current is already 
> on the $PATH then the new python will be found; I think that would be 
> easy to check).

That's a bug, please file a report at bugs.python.org.

> - It adds a bunch of links to /usr/local/bin even though that is 
> redundant with putting Python's bin directory on the $PATH. This makes 
> it a headache to switch Python versions -- something developers often 
> need to do when testing compatibility.

This behavior can be disabled when you run the installer. I agree that the default should be to not install files in /usr/local, although we have had users that complained that the 3.x installers didn't do this.

BTW. I've talked with Ned about this feature at Pycon and we'd like to move to a python-select command that gives you a command-line tool for managing the path to the current python (simular to gcc-select or xcode-select).   That way it should be possible to do away with automaticly patching the shell profile.

Ronald


More information about the Pythonmac-SIG mailing list