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

GRASS GIS trac at osgeo.org
Tue Apr 2 12:53:25 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 mmetz):

 Replying to [comment:11 pmav99]:
 > Well, the next steps are to get rid of {{{PYTHONPATH}}} and
 {{{LD_LIBRARY_PATH}}} too. {{{PYTHONPATH}}} should be rather easy via a
 path configuration file (e.g. {{{grass.pth}}} -
 [https://docs.python.org/3/library/site.html source]). Not sure how easy
 is going to be to get rid of {{{LD_LIBRARY_PATH}}} but at least in theory
 if you figure out the appropriate linker options, it is doable.

 I still don't understand why you want to load the GRASS Python library
 outside a GRASS session: you can't use it unless a GRASS session with a
 `GISRC` file containing `GISDBASE`, `LOCATION_NAME`, and `MAPSET` has been
 defined, otherwise GRASS executables will fail.

 Setting `PYTHONPATH` and `LD_LIBRARY_PATH` is not sufficient: `PATH` must
 include the path to GRASS executables, otherwise the GRASS Python library
 will not work because it calls GRASS executables which are expected to be
 in `PATH`.

 Moreover, you can't just set `PYTHONPATH` and `LD_LIBRARY_PATH`, you need
 to prepend or append the corresponding GRASS paths if `PYTHONPATH` or
 `LD_LIBRARY_PATH` are already set.

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



More information about the grass-dev mailing list