[GRASS-dev] [GRASS-SVN] r67282 - grass/trunk/lib/python/script

Hi Martin,

···

On Sun, Dec 20, 2015 at 10:04 AM, <svn_grass@osgeo.org> wrote:

Author: martinl
Date: 2015-12-20 07:04:40 -0800 (Sun, 20 Dec 2015)
New Revision: 67282

Modified:
grass/trunk/lib/python/script/setup.py
Log:
pythonlib: add wxpython modules to pythonpath when calling gsetup.init()

Modified: grass/trunk/lib/python/script/setup.py

— grass/trunk/lib/python/script/setup.py 2015-12-20 13:51:21 UTC (rev 67281)
+++ grass/trunk/lib/python/script/setup.py 2015-12-20 15:04:40 UTC (rev 67282)
@@ -174,7 +174,7 @@

Set PYTHONPATH to find GRASS Python modules

TODO: isn’t this useless? user already imported this somehow

path = os.getenv(‘PYTHONPATH’)

  • etcpy = os.path.join(gisbase, ‘etc’, ‘python’)
  • etcpy = os.path.join(gisbase, ‘etc’, ‘python’) + os.pathsep + os.path.join(gisbase, ‘gui’, ‘wxpython’)
    if path:
    path = etcpy + os.pathsep + path
    else:

I think this is too risky. If I understand it correctly, it puts all the GUI modules/packages on path. So, one will get:

animation
core
datacatalog
dbmgr
docs
gcp

Considering the amount and naming, it is likely to get name collision. This will happen even if the caller doesn’t have any interest in GUI.

Simple way to solve this would be adding GUI to path optionally by a parameter or by providing a separate function.

Better way to solve this is probably putting GUI modules/packages to a bigger package. Let’s say grassgui, or perhaps grasswxgui. Another option is to have grass.wxgui package. In this case, putting things to etc/python/ would be mandatory, in the other cases it is optional.

Vaclav

https://trac.osgeo.org/grass/changeset/67282

Hi,

2015-12-21 15:33 GMT+01:00 Vaclav Petras <wenzeslaus@gmail.com>:

I think this is too risky. If I understand it correctly, it puts all the GUI
modules/packages on path. So, one will get:

right.

Considering the amount and naming, it is likely to get name collision. This
will happen even if the caller doesn't have any interest in GUI.

Simple way to solve this would be adding GUI to path optionally by a
parameter or by providing a separate function.

I used just for now the simple way (r67308).

Better way to solve this is probably putting GUI modules/packages to a
bigger package. Let's say grassgui, or perhaps grasswxgui. Another option is
to have grass.wxgui package. In this case, putting things to etc/python/
would be mandatory, in the other cases it is optional.

Assuming that the most of users will need only to run g.gui.* modules
via run_command() it would be probably enough to add path check to the
every g.gui.* module...

Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

Hi,

2015-12-21 15:33 GMT+01:00 Vaclav Petras <wenzeslaus@gmail.com>:

I think this is too risky. If I understand it correctly, it puts all the GUI
modules/packages on path. So, one will get:

btw, there is similar issue in grass.py startup script [1]. Ma

[1] https://trac.osgeo.org/grass/browser/grass/trunk/lib/init/grass.py#L577

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Mon, Dec 21, 2015 at 2:05 PM, Martin Landa <landa.martin@gmail.com>
wrote:

2015-12-21 15:33 GMT+01:00 Vaclav Petras <wenzeslaus@gmail.com>:
> I think this is too risky. If I understand it correctly, it puts all the
GUI
> modules/packages on path. So, one will get:

btw, there is similar issue in grass.py startup script [1]. Ma

[1]
https://trac.osgeo.org/grass/browser/grass/trunk/lib/init/grass.py#L577

Yes. I think that the problem is little bit more likely to happen with
setup.init than for "GRASS scripts".

But perhaps we should remove it from there. There is a limited number of
places where some sort of GUI is started, so perhaps it should be done
manually everywhere as you already suggested for g.gui. modules.

Hi,

2015-12-21 22:22 GMT+01:00 Vaclav Petras <wenzeslaus@gmail.com>:

But perhaps we should remove it from there. There is a limited number of
places where some sort of GUI is started, so perhaps it should be done
manually everywhere as you already suggested for g.gui. modules.

done in r67310. Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa