What is the difference between Python's 'Extras' and 'site-packages' directories?

I am confused about how Python, on OS X, uses packages in "Extras" and "site-packages". In particular, I am confused about what I see in these directories and how duplicate packages in directories affect each other and where should I install the packages I am installing.

I assumed that "Extras" 1 is the location for packages that are not part of the Python kernel, but are distributed with the platform. For example, OS X is distributed with PyObjC

, twisted

and numpy

, among others; and they are in the "Advanced" section. I also assumed that the "site-packages" 2 were the packages that I would later install, and that the directory was empty or missing on the "new" machine. Also, I assumed that installing a new package would leave the version in "Extras" separately and put any updates I make in "site-packages" where they "mask" those in "Extra". (So, for example, a default installation can simply be restored by removing "site-packages".)

What confuses me is that the contents of my "Extras" directory are shrinking. Compared to content in a fresh OS X installation (10.8.2), there is no "Extras" for my current configuration

altgraph
altgraph-0.9-py2.7.egg-info
dateutil
macholib
macholib-1.4.2-py2.7.egg-info
modulegraph
modulegraph-0.9.1-py2.7.egg-info
numpy #though numpy-1.6.1-py2.7.egg-info is there
pkg_resources.py  # though .pyc is there
py2app
py2app-0.6.3-py2.7.egg-info
setuptools  # though setuptools-0.6c12dev_r88846-py2.7.egg-info is there
site.py  # though .pyc and .pyo are there
xattr
xattr-0.6.2-py2.7.egg-info
zope
zope.interface-3.5.1-py2.7.egg-info

      

and has two additional files not found in the new installation

pkg_resources.py.OLD.1356069438.31
setuptools-0.6c12dev_r88846-py2.7.egg-info.OLD.1356069438.31
setuptools.OLD.1356069438.31

      

To the best of my recollection, these are all packages that I updated myself, and all versions are present in the "site-packages".

Is the content of the Advanced directory "drained" in this way? Does the package that is in the "Extras" section "move" it to the "site-packages", or if the "Extras" versions are left alone and just "masked" by those in the "sites-packages"?


1 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python


2:/Library/Python/2.7/site-packages/

+2


source to share


1 answer


OSX (and Linux) doesn't seem to want to install additional python packages in the default install directory for the python distribution.

pip can search (like python itself) for installed modules, and if you do an upgrade, you uninstall the old version and install the new version in the location you asked for by default for site packages. If you look closely at the output of pip, it will tell you what it uninstalled and what it installed.

So, if you point pip to install to the Extras directory, or if you have a patch to do this for OSX by default, it will work.



It is actually good that the old versions are removed, as otherwise the version of the imported module will depend on your search path (sys.path) and this is error prone.

Can I argue that it is supposed to be downsized, but this is the usual result of how you do updates with pip.

+1


source







All Articles