[Python-modules-team] Bug#620551: any resolution?

Yaroslav Halchenko debian at onerussian.com
Tue Jan 22 17:28:09 UTC 2013


Hi,

> One simple solution would be to run the script under the symlink path
> /usr/lib/pymodules/python2.6/ppworker.py.
> Then /usr/lib/pymodules/python2.6/ would be added (again) to sys.path,
> which is harmless.

FWIW that would not help apparently since

pp already does that:

DEBUG4:  ['/usr/bin/python', '-u', '/usr/lib/pymodules/python2.7/ppworker.py', '2>/dev/null']

my printout of _Worker.command

the problem is that Python is not only adding the parent directory of a
script to the path, but it follows symlinks for the file first:

novo:/tmp
$> ls -l **/print_path.py 
lrwxrwxrwx 1 yoh yoh  20 Jan 22 12:11 X/Y/print_path.py -> /tmp/X/print_path.py
lrwxrwxrwx 1 yoh yoh  18 Jan 22 12:11 X/print_path.py -> /tmp/print_path.py
-rw------- 1 yoh yoh 101 Jan 22 11:36 print_path.py
$> python print_path.py 
sys.path ['/tmp', '/home/yoh/.local/lib/python2.7/site-packages/nosecomplete-0.0.4-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/yoh/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/InsightToolkit/WrapITK/Python', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/stfio', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
PYTHONPATH empty
$> python X/print_path.py 
sys.path ['/tmp', '/home/yoh/.local/lib/python2.7/site-packages/nosecomplete-0.0.4-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/yoh/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/InsightToolkit/WrapITK/Python', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/stfio', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
PYTHONPATH empty
$> python X/Y/print_path.py 
sys.path ['/tmp', '/home/yoh/.local/lib/python2.7/site-packages/nosecomplete-0.0.4-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/yoh/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/InsightToolkit/WrapITK/Python', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/stfio', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
PYTHONPATH empty


What about for now just explicitly removing pyshared from the sys.path of
the ppworker?

$> quilt diff
--- a/ppworker.py
+++ b/ppworker.py
@@ -109,7 +109,17 @@ class _WorkerProcess(object):
 
 if __name__ == "__main__":
         # add the directory with ppworker.py to the path
-        sys.path.append(os.path.dirname(__file__))
+
+        # Debian: no need -- pp is already in the path + breaks 
+        #         imports of other modules, see #620551
+        # sys.path.append(os.path.dirname(__file__))
+
+        # Debian: actually infiltrate the path so no problematic
+        #         directories are in the path
+        for d in ('/usr/share/pyshared',):
+             if d in sys.path:
+                 sys.path.remove(d)
+
         wp = _WorkerProcess()
         wp.run()


Sandro?

-- 
Yaroslav O. Halchenko
Postdoctoral Fellow,   Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        



More information about the Python-modules-team mailing list