[GRASS-dev] Python script dependencies

Hi team,

I have some python modules developed in a toolbox and install them all using g.extension with the SUBDIRS Makefile variable. I frequently feel like I need to share code between those modules, i.e. I would like to create a utility module that can be imported by all other modules in the toolbox. I managed to install the module in the .grass7/addons/script directory, but the installation of the other modules fails because they cant import the utilities yet. Installing it like any other module seems to bring all sorts of problems including the requirement to include the toolbox name that has dots in them preventing a python import.

How would I best go about this?

Thanks a lot,
Michel



Hi Michael,

Have a look at e.g. https://github.com/pesekon2/GRASS-GIS-SOS-tools/tree/master/sos or

https://trac.osgeo.org/grass/browser/grass-addons/grass7?order=name#gui/wxpython/wx.metadata

for inspiration regarding addon-libraries (in Python).

Kind regards,

Stefan

···

From: grass-dev grass-dev-bounces@lists.osgeo.org On Behalf Of Michel Wortmann
Sent: tirsdag 23. oktober 2018 11:20
To: grass-dev grass-dev@lists.osgeo.org
Subject: [GRASS-dev] Python script dependencies

Hi team,

I have some python modules developed in a toolbox and install them all using g.extension with the SUBDIRS Makefile variable. I frequently feel like I need to share code between those modules, i.e. I would like to create a utility module that can be imported by all other modules in the toolbox. I managed to install the module in the .grass7/addons/script directory, but the installation of the other modules fails because they cant import the utilities yet. Installing it like any other module seems to bring all sorts of problems including the requirement to include the toolbox name that has dots in them preventing a python import.

How would I best go about this?

Thanks a lot,

Michel



Great, thanks Stefan!
I find those standard Makefiles deserve a mention in the GRASS and Python documentation somewhere.

Michel

On 23 Oct 2018, at 11:25, Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote:

Hi Michael,

Have a look at e.g.https://github.com/pesekon2/GRASS-GIS-SOS-tools/tree/master/sos or
https://trac.osgeo.org/grass/browser/grass-addons/grass7?order=name#gui/wxpython/wx.metadata
for inspiration regarding addon-libraries (in Python).

Kind regards,
Stefan

From: grass-dev <grass-dev-bounces@lists.osgeo.org> On Behalf Of Michel Wortmann
Sent: tirsdag 23. oktober 2018 11:20
To: grass-dev <grass-dev@lists.osgeo.org>
Subject: [GRASS-dev] Python script dependencies

Hi team,

I have some python modules developed in a toolbox and install them all using g.extension with the SUBDIRS Makefile variable. I frequently feel like I need to share code between those modules, i.e. I would like to create a utility module that can be imported by all other modules in the toolbox. I managed to install the module in the .grass7/addons/script directory, but the installation of the other modules fails because they cant import the utilities yet. Installing it like any other module seems to bring all sorts of problems including the requirement to include the toolbox name that has dots in them preventing a python import.

How would I best go about this?

Thanks a lot,
Michel

-------------------------
* Michel Wortmann
* Post-doc
* Potsdam Institute for Climate Impact Research (PIK)
* Telegrafenberg A62, 14473 Potsdam, Germany
* Tel.: 0049 (0)331 288 2546
* E-mail: wortmann@pik-potsdam.de <mailto:wortmann@pik-potsdam.de>
* Internet: www.pik-potsdam.de/members/wortmann <http://www.pik-potsdam.de/members/wortmann&gt;
-------------------------

Good point!

Added two bullet-points here: https://trac.osgeo.org/grass/wiki/Submitting

Cheers

Stefan

···

From: Michel Wortmann wortmann@pik-potsdam.de
Sent: tirsdag 23. oktober 2018 13:27
To: Stefan Blumentrath Stefan.Blumentrath@nina.no
Cc: grass-dev grass-dev@lists.osgeo.org
Subject: Re: [GRASS-dev] Python script dependencies

Great, thanks Stefan!

I find those standard Makefiles deserve a mention in the GRASS and Python documentation somewhere.

Michel

On 23 Oct 2018, at 11:25, Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote:

Hi Michael,

Have a look at e.g.https://github.com/pesekon2/GRASS-GIS-SOS-tools/tree/master/sos or

https://trac.osgeo.org/grass/browser/grass-addons/grass7?order=name#gui/wxpython/wx.metadata

for inspiration regarding addon-libraries (in Python).

Kind regards,

Stefan

From: grass-dev <grass-dev-bounces@lists.osgeo.org> On Behalf Of Michel Wortmann
Sent: tirsdag 23. oktober 2018 11:20
To: grass-dev <grass-dev@lists.osgeo.org>
Subject: [GRASS-dev] Python script dependencies

Hi team,

I have some python modules developed in a toolbox and install them all using g.extension with the SUBDIRS Makefile variable. I frequently feel like I need to share code between those modules, i.e. I would like to create a utility module that can be imported by all other modules in the toolbox. I managed to install the module in the .grass7/addons/script directory, but the installation of the other modules fails because they cant import the utilities yet. Installing it like any other module seems to bring all sorts of problems including the requirement to include the toolbox name that has dots in them preventing a python import.

How would I best go about this?

Thanks a lot,

Michel



* Stefan Blumentrath <Stefan.Blumentrath@nina.no> [2018-10-24 08:03:58 +0000]:

Good point!
Added two bullet-points here: https://trac.osgeo.org/grass/wiki/Submitting

By the way,

g.extension r.green
Fetching <r.green> from GRASS GIS Addons repository (be patient)...
Compiling...
Traceback (most recent call last):
  File "/tmp/grass7-nik-27424/tmpm7f5Qj/r.green/scripts/r.green.hydro.structure", line 139, in <module>
    from libgreen.checkparameter import check_required_columns, exception2error
ImportError: No module named libgreen.checkparameter
make[2]: *** [/osgeo/grasstrunk/dist.x86_64-pc-linux-gnu/include/Make/Html.make:14: r.green.hydro.structure.tmp.html] Error 1
Installing...
/usr/bin/install: cannot stat '/tmp/grass7-nik-27424/tmpm7f5Qj/r.green/docs/html/r.green.hydro.structure.html': No such file or directory
make[2]: *** [/osgeo/grasstrunk/dist.x86_64-pc-linux-gnu/include/Make/Script.make:36: install] Error 1
Updating addons metadata file...
Installation of <r.green> successfully finished

Nikos