[GRASS-dev] r67535: pygrass: change dirname in set_path()

Hi Martin,

I saw your recent comment in the set_path function:

{{{

TODO: why dirname is checked first - the logic should be revised

TODO probably also ‘path’ should be also removed - it’s used only by

compilation process for addons (see r.green for details)

}}}

‘path’ it is not used for compilation process for addons as you said. ‘path’ is used to run the code locally without compilation.

In this way it is possible to just unpack the module and call the sub-modules locally, compilation is not needed at all… This it is particularly useful during the development phase but not only. It works quite well also to overcome eventually g.extension problems.

Of course dirname must be checked before the default path, other wise it is too late…

Any comments?

Have a nice day

Pietro

Hi,

2016-01-11 12:16 GMT+01:00 Pietro <peter.zamb@gmail.com>:

Of course dirname must be checked before the default path, other wise it is
too late...

hm, what means `dirname`? I got impression that it's used for

$GRASS_ADDON_BASE/etc/r.mymodule

is find by set_path('r.mymodule')

$GRASS_ADDON_BASE/etc/r.mymodule/lib1

is find by set_path('r.mymodule', 'lib1'). From this logic I don't
understand why dirname must be set. Martin

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

Hi Martin,

Sorry for the delay.

On Tue, Jan 12, 2016 at 7:11 PM, Martin Landa <landa.martin@gmail.com> wrote:

hm, what means `dirname`? I got impression that it's used for

$GRASS_ADDON_BASE/etc/r.mymodule

is find by set_path('r.mymodule')

$GRASS_ADDON_BASE/etc/r.mymodule/lib1

is find by set_path('r.mymodule', 'lib1'). From this logic I don't
understand why dirname must be set. Martin

dirname must be set to check if the directory is available when using
the code locally, if dirname is available in the local specified path
then add the path to sys.path, otherwise try to find the correct path
within the GRASS standard paths.
I've added some more documentation to clarify this point.

Let me know if you think is still not clear. :slight_smile:

all the best

Pietro

Hi Pietro,

2016-01-25 11:31 GMT+01:00 Pietro <peter.zamb@gmail.com>:

I've added some more documentation to clarify this point.

Thanks, Martin

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

In r67669 I moved the functions to grass.script.utils to avoid ctypes dependency. Backwards compatibility is kept. Documentation says depreciated. Old functions can be removed in 8.0.

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

···

On Mon, Jan 25, 2016 at 5:31 AM, Pietro <peter.zamb@gmail.com> wrote:

Hi Martin,

Sorry for the delay.

On Tue, Jan 12, 2016 at 7:11 PM, Martin Landa <landa.martin@gmail.com> wrote:

hm, what means dirname? I got impression that it’s used for

$GRASS_ADDON_BASE/etc/r.mymodule

is find by set_path(‘r.mymodule’)

$GRASS_ADDON_BASE/etc/r.mymodule/lib1

is find by set_path(‘r.mymodule’, ‘lib1’). From this logic I don’t
understand why dirname must be set. Martin

dirname must be set to check if the directory is available when using
the code locally, if dirname is available in the local specified path
then add the path to sys.path, otherwise try to find the correct path
within the GRASS standard paths.
I’ve added some more documentation to clarify this point.

Let me know if you think is still not clear. :slight_smile:

all the best

Pietro


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Hi,

2016-01-25 21:05 GMT+01:00 Vaclav Petras <wenzeslaus@gmail.com>:

In r67669 I moved the functions to grass.script.utils to avoid ctypes
dependency. Backwards compatibility is kept. Documentation says depreciated.
Old functions can be removed in 8.0.

thanks, make sense to me. Ma

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

On Mon, Jan 25, 2016 at 5:31 AM, Pietro <peter.zamb@gmail.com> wrote:

On Tue, Jan 12, 2016 at 7:11 PM, Martin Landa <landa.martin@gmail.com> wrote:

hm, what means dirname? I got impression that it’s used for

$GRASS_ADDON_BASE/etc/r.mymodule

is find by set_path(‘r.mymodule’)

$GRASS_ADDON_BASE/etc/r.mymodule/lib1

is find by set_path(‘r.mymodule’, ‘lib1’). From this logic I don’t
understand why dirname must be set. Martin

dirname must be set to check if the directory is available when using
the code locally, if dirname is available in the local specified path
then add the path to sys.path, otherwise try to find the correct path
within the GRASS standard paths.
I’ve added some more documentation

I’m still unsure whether we cover all cases correctly. Shouldn’t the compilation path options precede the normal ones?

On Mon, Jan 25, 2016 at 9:05 PM, Vaclav Petras <wenzeslaus@gmail.com> wrote:

In r67669 I moved the functions to grass.script.utils to avoid ctypes
dependency. Backwards compatibility is kept. Documentation says depreciated.
Old functions can be removed in 8.0.

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

For the record, added to
https://trac.osgeo.org/grass/wiki/Grass8Planning

Markus