[GRASS-dev] [GRASS GIS] #3772: Make the grass library importable outside of a GRASS session

GRASS GIS trac at osgeo.org
Sat Mar 30 07:29:02 PDT 2019


#3772: Make the grass library importable outside of a GRASS session
--------------------------+-------------------------
  Reporter:  pmav99       |      Owner:  grass-dev@…
      Type:  enhancement  |     Status:  new
  Priority:  normal       |  Milestone:
 Component:  Python       |    Version:  svn-trunk
Resolution:               |   Keywords:
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+-------------------------

Comment (by pmav99):

 Added a patch that makes it possible to import the GRASS library even from
 a normal shell session.

 After applying the patch and compiling, the code can be tested with:
 {{{
 LD_LIBRARY_PATH=dist.x86_64-pc-linux-gnu/lib PYTHONPATH=dist.x86_64-pc-
 linux-gnu/etc/python python -c 'import grass.script' && echo 'OK!'
 }}}

 The patch itself does 2 things:
 1. It does not resolve the path to {{{GISBASE}}} by using the ENV variable
 but by using the relative path from {{{dist.x86_64-pc-linux-
 gnu/etc/python/grass/__init__.py}}}
 2. It moves the caching of the GRASS commands from the
 {{{lib/python/pygrass/modules/shortcuts}}} module to the {{{MetaModule}}}
 class itself.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3772#comment:8>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list