[Distutils] eggs and import order

Phillip J. Eby pje at telecommunity.com
Wed Oct 29 17:55:23 CET 2008


At 11:40 AM 10/29/2008 -0500, skip at pobox.com wrote:
>Way back when I installed SQLalchemy 0.3.3 in such a way that it wound up in
>.../site-packages/easy-install.pth:
>
>     ...
>     ./SQLAlchemy-0.3.3-py2.4.egg
>     ...
>
>A colleague installed a later version in a different directory, referenced
>that in PYTHONPATH but still got the old version:
>
>     udesktop116% 
> PYTHONPATH=/opt/tradelink/research/site-packages.beta python -c 
> 'import sqlalchemy ; print sqlalchemy.__file__'
> 
>/opt/app/g++lib6/python-2.4/lib/python2.4/site-packages/SQLAlchemy-0.3.3-py2.4.egg/sqlalchemy/__init__.pyc
>     udesktop116% ls /opt/tradelink/research/site-packages.beta
>     BeautifulSoup.py                        _mssql.so               pylab.py
>     Cython                                  configobj.py            pylab.pyc
>     IPython                                 dateutil 
> pymssql.py
>     Jinja-1.2-py2.4-solaris-2.10-i86pc.egg  docutils-0.4-py2.4.egg 
> pymssql.pyc
>     PIL                                     easy-install.pth 
> pyparsing.py
>     PIL.pth                                 enthought               pytz
>     Pygments-0.10-py2.4.egg                 fpconst.py              pyximport
>     Pyrex                                   fpconst.pyc             research
>     SOAPpy                                  lib                     scipy
>     SQLAlchemy-0.5.0rc3dev_r5205-py2.4.egg  matplotlib 
> timeseries
>     Sphinx-0.3-py2.4.egg                    mpl_toolkits            tlsec
>     Symbide-0.3.1-py2.4.egg                 numpy
>     __init__.py                             pyExcelerator

There's a special 'site.py' missing from this directory.  You can fix 
that by doing this:

     cd /opt/tradelink/research/site-packages.beta
     PYTHONPATH=. easy_install -d . SQLAlchemy-0.5.0rc3dev_r5205-py2.4.egg

My guess is that this directory was created by copying a 
site-packages directory from somewhere, or by easy_installing to it 
with the --site-dirs option.  Either would have prevented 
easy_install from creating the site.py that's necessary to make this work.

Without the special site.py, Python doesn't pick this directory up as 
a "site" directory, and doesn't process PYTHONPATH eggs properly.

Note that you must use easy_install as described above to do this; 
you can't just copy Python's site.py, as it's not the same file.  The 
one easy_install puts there forces .pth processing to occur on 
PYTHONPATH, and then invokes the original Python site.py.



More information about the Distutils-SIG mailing list