system installed eggs overriding buildout provided packages

Bug #389065 reported by Stuart Bishop
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Gary Poster

Bug Description

bin/py and bin/harness are seeing different versions of the pytz library. This is because bin/py uses PYTHONPATH to set the search path, so it gets set incorrectly, unlike bin/harness which sets sys.path directly.

$ bin/py
Python 2.4.6 (#2, Mar 19 2009, 10:02:47)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.4/site-packages/pytz-2008c-py2.4.egg', <....>, '/home/stub/lp/lp-sourcedeps/eggs/pytz-2009j-py2.4.egg', <...>]
>>>

$ bin/harness
execute_zcml_for_scripts()...
xmlconfig.file()...
Reading $PYTHONSTARTUP...
Initializing storm...
Creating the factory...

>>> sys.path
['/home/stub/lp/trivial/lib', <....> , '/home/stub/lp/lp-sourcedeps/eggs/pytz-2009j-py2.4.egg', <....>, '/usr/lib/python2.4/site-packages/pytz-2008c-py2.4.egg', <.....>]
>>>

Related branches

Stuart Bishop (stub)
Changed in launchpad-foundations:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Stuart Bishop (stub) wrote :

So this isn't actually a problem, because our scripts all do 'import _pythonpath' which resets the path correctly. Well... almost all of our scripts do. Some of the scripts in database/schema are so old they don't use this mechanism and cause warnings to be raised about module conflicts.

Stuart Bishop (stub)
Changed in launchpad-foundations:
assignee: nobody → Stuart Bishop (stub)
status: Confirmed → In Progress
Stuart Bishop (stub)
Changed in launchpad-foundations:
status: In Progress → Fix Committed
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Actually, the _pythonpath kludge isn't a solution. The fact that bin/py and bin/test have wrong paths is causing many other problems. Especially, it prevented Leonard from adding a merge target for launchpadlib because the tests would always be run from the system launchpadlib.

Changed in launchpad-foundations:
assignee: Stuart Bishop (stub) → Gary Poster (gary)
status: Fix Committed → Triaged
Revision history for this message
Stuart Bishop (stub) wrote :

I think we can use the PYTHONSTARTUP environment variable to rewrite the path so the buildout installed libraries come before the system libraries.

Changed in launchpad-foundations:
status: Triaged → In Progress
Revision history for this message
Gary Poster (gary) wrote :

We now have a branch (sitepackages-ng-1) merged that addresses the concerns Francis raises in comment #2. With that branch, when I compare the sys.path for bin/py and bin/harness, I get different order for the paths, but the exact same eggs in a set comparison.

I tried the PYTHONSTARTUP approach that Stuart suggested. This works well for running bin/py in the interactive prompt but PYTHONSTARTUP has no affect on using bin/py to run scripts (it is described in ``python -h`` as "PYTHONSTARTUP: file executed on interactive startup (no default)"). Therefore it does not work for all of our use cases.

I'm going to optimistically declare this fixed via my buildout branch, and stick with the use of PYTHONPATH.

If we have further problems with bin/py, we can investigate using the Python-interpreter-alike that zc.recipe.egg can produce. It does not and cannot support all of the options that the normal Python binary offers, and we use some of them in the Makefile, so it might need some care in the switch.

Changed in launchpad-foundations:
status: In Progress → Fix Committed
Gary Poster (gary)
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
Revision history for this message
Stuart Bishop (stub) wrote :

I'm seeing this again:

$ bin/py
Python 2.5.5 (r255:77872, Jan 31 2010, 21:34:29)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytz
>>> pytz.__version__
'2009e'
>>> import sys
>>> sys.path
['', '/usr/lib/python2.5/site-packages/pytz-2009e-py2.5.egg', '/home/stub/lp/trivial/parts/scripts', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/home/stub/lp/lp-sourcedeps/eggs/setuptools-0.6c11-py2.5.egg', '/home/stub/lp/trivial/lib', '/home/stub/lp/lp-sourcedeps/eggs/windmill-1.3beta3_lp_r1440-py2.5.egg', '/home/stub/lp/lp-sourcedeps/eggs/funkload-1.10.0-py2.5.egg', '/home/stub/lp/lp-sourcedeps/eggs/zc.zservertracelog-1.1.5-py2.5.egg', '/home/stub/lp/lp-sourcedeps/eggs/zope.server-3.6.1-py2.5.egg'

Changed in launchpad-foundations:
status: Fix Released → Confirmed
Revision history for this message
Gary Poster (gary) wrote :

1) I'm guessing this is Karmic? I can't install pytz on Lucid, for some reason, so I can't dupe.
2) Did this only start to happen after you installed distribute (bug 564680)? I haven't tried that yet.
3) Was this true after a fresh build, or a make clean && make?
4) Could you attach your bin/py and your parts/scripts/site.py?

Revision history for this message
Stuart Bishop (stub) wrote :

This was Jaunty.

I do not know if this was happening before installing distribute.

This was true after a make clean & make.

bin/py and parts/scripts/site.py won't be available until next week.

Revision history for this message
Stuart Bishop (stub) wrote :

Argh.... Lucid.... I meant this was Lucid.

Revision history for this message
Gary Poster (gary) wrote :

I was able to duplicate. This is a new bug having to do with Distribute support. I opened bug 568486, and have a branch with a fix but no automated tests yet (which will be a bit annoying to write). I'm closing this bug again.

Changed in launchpad-foundations:
status: Confirmed → Fix Committed
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.