[GRASS-dev] Question for set_gui_path()

Panagiotis Mavrogiorgos pmav99 at gmail.com
Wed Jan 30 14:51:48 PST 2019


I am trying to wrap my head around grass initialization, which
unfortunately is not that easy, so bear with me if I ask something stupid.

In grass/script/setup.py there is a function called set_gui_path():

def set_gui_path():
    """Insert wxPython GRASS path to sys.path."""
    gui_path = os.path.join(os.environ['GISBASE'], 'gui', 'wxpython')
    if gui_path and gui_path not in sys.path:
        sys.path.insert(0, gui_path)

As you can see it has a very specific side-effect, i.e. it adds
GISBASE/gui/wxpython to sys.path.

This function was introduced in 67310
<https://trac.osgeo.org/grass/changeset/67310> and is being called in a
bunch of gui/wxpython modules:

gui/wxpython/photo2image/g.gui.photo2image.py
gui/wxpython/image2target/g.gui.image2target.py
gui/wxpython/gmodeler/g.gui.gmodeler.py
gui/wxpython/timeline/g.gui.timeline.py
gui/wxpython/rlisetup/g.gui.rlisetup.py
gui/wxpython/vdigit/g.gui.vdigit.py
gui/wxpython/animation/g.gui.animation.py
gui/wxpython/startup/locdownload.py
gui/wxpython/mapswipe/g.gui.mapswipe.py
gui/wxpython/dbmgr/g.gui.dbmgr.py
gui/wxpython/gcp/g.gui.gcp.py
gui/wxpython/psmap/g.gui.psmap.py
gui/wxpython/mapdisp/main.py
gui/wxpython/mapdisp/test_mapdisp.py
gui/wxpython/iclass/g.gui.iclass.py
gui/wxpython/gui_core/pyedit.py
gui/wxpython/gui_core/goutput.py
gui/wxpython/gui_core/ghelp.py
gui/wxpython/gui_core/forms.py
gui/wxpython/gui_core/treeview.py
gui/wxpython/gui_core/simplelmgr.py
gui/wxpython/datacatalog/g.gui.datacatalog.py
gui/wxpython/modules/mapsets_picker.py
gui/wxpython/tplot/g.gui.tplot.py

Nevertheless, if we start the GUI, and check sys.path in the embedded
python console,
we see that GISBASE/gui/wxpython has been already added to the path;
probably due to one of those calls:

>>> import sys
>>> sys.path
['/home/pmav99/Prog/svn/grass_svn/dist.x86_64-pc-linux-gnu/gui/wxpython',
 '/home/pmav99/Prog/svn/grass_svn/dist.x86_64-pc-linux-gnu/etc/python',
 '/usr/lib/python37.zip',
 '/usr/lib/python3.7',
 '/usr/lib/python3.7/lib-dynload',
 '/home/pmav99/Prog/svn/grass_svn/venv3/lib/python3.7/site-packages',
 '/home/pmav99/Prog/svn/grass_svn/dist.x86_64-pc-linux-gnu/etc/r.in.wms'
]

So if GISBASE/gui/wxpython is needed to be in sys.path for the GUI to work
correctly, what is the problem with adding it once when the GUI starts and
be done with it?

with kind regards,
Panos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20190131/e35548b1/attachment.html>


More information about the grass-dev mailing list