[Distutils] easy_install execution question

Ned Deily nad at acm.org
Fri Oct 28 09:09:24 CEST 2011


In article 
<CAKCGbV4u_2mE3TTa6TLAGj+WB5pM1fT0gKtiywin9XZXMnfPKw at mail.gmail.com>,
 Paul Ivanov <pivanov314 at gmail.com> wrote:

> Hi Chris,
> 
> On Thu, Oct 27, 2011 at 7:43 PM, Chris Jerdonek
> <chris.jerdonek at gmail.com> wrote:
> > Hi, I have one more question for the time being.  This regards how the
> > easy_install script works.
> >
> > I use Mac OSX, and my /usr/bin directory contains three versions of
> > the easy_install script: easy_install, easy_install-2.5, and
> > easy_install-2.6.
> >
> > Based on some debugging lines I tried inserting, when I execute the
> > script called simply "easy_install", the script seems to execute just
> > the first line (namely "#!/usr/bin/python"), and then seems to
> > immediately jump to executing easy_install-2.6.
> >
> > I was curious about the mechanism that allows the Python interpreter
> > to jump mysteriously from one file to another.  This doesn't seem to
> > be evident from the easy_install scripts themselves.  What causes this
> > behavior?
> 
> It appears to be this way, because your /usr/bin/python points to python2.6.
> $ ls -l `which python`
> lrwxrwxrwx 1 root root 9 2011-09-09 20:29 /usr/bin/python -> python2.6*
> 
> you can verify that no jumping occurs by printing a unique string in each of
>  `which easy_install` `which easy_install-2.6` `which easy_install-2.5`

Actually, it doesn't work that way on recent releases of Mac OS X.  
Apple implemented its own modifications to both Python and easy_install 
(setuptools) to support multiple versions; it does not use symlinks 
(unlike the MacPorts "port select" mechanism).   Rather, /usr/bin/python 
is a special wrapper executable and /usr/bin/easy_install a wrapper 
script that support persistently setting the default version in a plist 
via the defaults(1) command and/or temporarily changing the default via 
environment variable settings.  The mechanism is documented in the Apple 
man page for python.  Since neither /usr/bin/python nor 
/usr/bin/easy_install are symlinks, it's really important not to 
overwrite them.

-- 
 Ned Deily,
 nad at acm.org



More information about the Distutils-SIG mailing list