[GRASS-dev] [GRASS GIS] #2424: PyGRASS does not work when GRASS is invoked from outside
GRASS GIS
trac at osgeo.org
Mon Mar 12 18:18:24 PDT 2018
#2424: PyGRASS does not work when GRASS is invoked from outside
-------------------------+-------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.2.3
Component: Python | Version: svn-trunk
ctypes | Keywords: installation, pygrass, temporal,
Resolution: | scripts
CPU: | Platform: MSWindows 8
Unspecified |
-------------------------+-------------------------------------------------
Comment (by wenzeslaus):
These both help, but just to clarify, here we are concerned with only the
part of the Python API which uses `ctypes` in the background, i.e. not
`grass.script` which works just fine, but with `grass.temporal` and a
significant part of `grass.pygrass`.
Replying to [comment:12 neteler]:
> * Python: GRASS GIS 7 with an external library: grass-session:
This makes using `grass.script` much easier, but it is not possible to use
anything which calls ''ctypes'' (`grass.lib`), i.e. `grass.temporal` and
`grass.pygrass`, unless the dynamic libraries are loaded in some special
way (just changing `LD_LIBRARY_PATH` was not enough so far). (From
`grass.pygrass` I mean the part using `ctypes`, otherwise see the
comment:3 to comment:6 here.)
> * New easy-to-use CLI and API for GRASS GIS
In past your would have to do this (see comment:6 for details):
{{{
export LD_LIBRARY_PATH=$(grass70 --config path)/lib
python script_with_ctypes.py
}}}
Since 7.2 (after #2579, i.e. r65252), you can (see again comment:6 for
details):
{{{
grass ~/grassdata/nc_spm/test/ --exec script_with_ctypes.py
}}}
In regard to this ticket, the proposed CLI would work similarly to current
`--exec`. Same goes to the proposed Python API and the current APIs.
Nevertheless, `--exec` and the proposed CLI interface reduce the need to
load the libraries, for example, because the recommended way of using them
is to write a GRASS module and then call it using `--exec` - this way the
GRASS-specific part of the program is isolated and at the same time usable
as a separate GRASS module.
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2424#comment:13>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list