.pth and .egg-info files in /usr/lib/pymodules/python2.6 are not being processed

Bug #621348 reported by Gary Poster
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python2.6 (Debian)
Fix Released
Unknown
python2.6 (Ubuntu)
Invalid
Undecided
Barry Warsaw

Bug Description

Binary package hint: python2.6

On Lucid, .pth and .egg-info files in /usr/lib/pymodules/python2.6 are not being processed. It's because of how it is included, with a .pth file, IIRC.

This means that, for instance, bugs in repoze.what-1.0.8-py2.6-nspkg.pth are not triggered. It means that all of the .egg-info and .pth files in pymodules are pointless. That in turn means that any namespace packages there don't play nicely with the new zc.buildout because the .egg-info files are not processed. (I've carefully modified zc.buildout to mimic the exact behavior of site.py so that the repoze problem is not triggered; it would be really nice if the fix, whatever it is, still worked with my zc.buildout release.)

I have other examples, but the best quick instructions I have to dupe ATM are these. (1) apt install repoze.what. (2) It is already broken, but just to make sure, edit /usr/lib/pymodules/python2.6/repoze.what-1.0.8-py2.6-nspkg.pth (==/usr/share/pyshared/repoze.what-1.0.8-py2.6-nspkg.pth) to look horrible (my example: http://pastebin.ubuntu.com/481083/ ). (3) start python, and note that there are no complaints (they would be of the "site.py had problems, use -v for details" variety).

I'm pretty sure I see why this happens. The pymodules directory is added with a .pth file. That goes into lines 152-154 of site.py, in the addpackage module. For reference, that's the last three lines of this snippet.

        for line in f:
            if line.startswith("#"):
                continue
            if line.startswith(("import ", "import\t")):
                exec line
                continue
            line = line.rstrip()
            dir, dircase = makepath(sitedir, line)
            if not dircase in known_paths and os.path.exists(dir):
                sys.path.append(dir)
                known_paths.add(dircase)

That adds the path to sys.path but does *not* call addsitedir on it, so reading the directory for special files is not recursive. I *think* that's a Python behavior, so I'd prefer not to change it locally, myself.

My naive thought is that pymodules ought to be included within site.addsitepackages, the way the rest of the directories like this are, but maybe that's a bad idea for some reason.

Revision history for this message
Barry Warsaw (barry) wrote :

This is inherited from Debian. Squeeze has exactly the same behavior.

Revision history for this message
Barry Warsaw (barry) wrote :
Revision history for this message
Marc Tardif (cr3) wrote :

In addition to making the above snippet recursive by calling addsitedir expicitly, I think that the addpackage function would also have to be extended with pkg_resources.working_set.add_entry(sitedir) near the top in order for the directory to kick in. Just my observation from playing around with the bug.

Barry Warsaw (barry)
Changed in python2.6 (Ubuntu):
assignee: nobody → Barry Warsaw (barry)
milestone: none → later
Changed in python2.6 (Debian):
status: Unknown → New
Changed in python2.6 (Debian):
status: New → Fix Released
Revision history for this message
dino99 (9d9) wrote :

Support for this version has ended

Changed in python2.6 (Ubuntu):
status: New → Invalid
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.