[Python-Dev] Why does Mac OS X python share site-packages with apple python?

Ned Deily nad at acm.org
Sat Mar 3 22:57:39 CET 2012


In article <5A0E2490-A743-4729-A752-D94524EA9840 at barrys-emacs.org>,
 Barry Scott <barry at barrys-emacs.org> wrote:
> On my Mac OS X 10.7.3 System I have lots of python kits installed for 
> developing extensions.
> 
> I'll just noticed that Python.org 2.7.2 uses the sames site-packages folder 
> with Apple's
> 2.7.1.
> 
> Since extensions compiled against Apple's 2.7.1 segv when used by 
> python.org's 2.7.2
> this is at least unfortunate.
> 
> Here is the what is in sys.path for both versions. Notice 
> /Library/Python/2.7/site-packages
> is in both.

That directory is in the default sys.path for both the Apple-supplied 
Python 2.7 in Lion and for the python.org Python 2.7's but that doesn't 
mean both versions use the same site-packages directory:

$ /usr/bin/python2.7 -c "import distutils.sysconfig; \
        print(distutils.sysconfig.get_python_lib())"
/Library/Python/2.7/site-packages

$ /usr/local/bin/python2.7 -c "import distutils.sysconfig; \
        print(distutils.sysconfig.get_python_lib())"
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-pack
ages

That means that, by default, packages installed by Distutils-based 
installs (setup.py, easy_install, pip, et al) will be installed to the 
corresponding directory for each version.

The python.org OS X Pythons (and built-from-source framework builds) add 
the Apple-specific directory to the search path in order to allow 
sharing of installed third-party packages between the two.  The feature 
was added in 2.7 and 3.1+ and tracked in Issue4865 
(http://bugs.python.org/issue4865).  Please open a new issue on the 
tracker if you have examples of how this is causing problems.  Thanks.

-- 
 Ned Deily,
 nad at acm.org



More information about the Python-Dev mailing list