Almost. I applied the patch to my 2.4 version; below is output of a
pychecker call to a file that prints sys.path before and after the gtk
module import.
pychecker jnk.py
Processing jnk...
['', '/opt/vexcel/openev2/lib/python24.zip',
'/opt/vexcel/openev2/lib/python2.4',
'/opt/vexcel/openev2/lib/python2.4/plat-linux2',
'/opt/vexcel/openev2/lib/python2.4/lib-tk',
'/opt/vexcel/openev2/lib/python2.4/lib-dynload',
'/opt/vexcel/openev2/lib/python2.4/site-packages',
'/opt/vexcel/openev2/lib/python2.4/site-packages/Numeric',
'/opt/vexcel/openev2/lib/python2.4/site-packages/gtk-2.0']
['/opt/vexcel/openev2/lib/python2.4/site-packages/pychecker', '',
'/opt/vexcel/openev2/lib/python24.zip',
'/opt/vexcel/openev2/lib/python2.4',
'/opt/vexcel/openev2/lib/python2.4/plat-linux2',
'/opt/vexcel/openev2/lib/python2.4/lib-tk',
'/opt/vexcel/openev2/lib/python2.4/lib-dynload',
'/opt/vexcel/openev2/lib/python2.4/site-packages',
'/opt/vexcel/openev2/lib/python2.4/site-packages/Numeric',
'/opt/vexcel/openev2/lib/python2.4/site-packages/gtk-2.0']
Since the pychecker name and '' differ, the delete didn't work.
Is there any reason why we cannot preserve the path through the import?
import sys
_save_path = sys.path[:]
from _gtk import *
sys.path = _save_path
del sys, _save_path
This does work for my limited test cases.
Johan Dahlin wrote:
Jeffery D. Collins wrote:
I don't know if this is normal behavior, but importing gtk causes
sys.path to be modified. This holds for both pygtk-2.4.1 and
pygtk-2.6.x. The path the python module being run is getting loaded
into the first postion of sys.path. This happens normally when
python is run on a module, but gtk is inserting *another* one.
Why the extra one? This is particularly problematic for pychecker,
which modifies the path so that its own internal modules are exposed
last in sys.path. Some debugging reveals that its the _gtk extension
module that causes the change, but I was not able to determine where
the change is being made.
Thanks for reporting this, I just fixed it in CVS.
The problem was that we're calling PySys_SetArgv, because we want to
remove all options from argv which gtk+ ate up. However PySys_Argv is
a little stupid and always inserts argv[0] into sys.path.
Can you check and see if it solves your problems?
Thanks
Johan
--
Jeffery D. Collins
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/