[GRASS-dev] [GRASS GIS] #3772: Make the grass library importable outside of a GRASS session
GRASS GIS
trac at osgeo.org
Mon Apr 1 01:26:28 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 mlennert):
Replying to [comment:8 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}}}
I have to admit I don't really understand why all this code is necessary
just to be able to do
{{{
LD_LIBRARY_PATH=/usr/lib/grass74/lib
PYTHONPATH=/usr/lib/grass74/etc/python python -c 'import grass.script' &&
echo 'OK!
}}}
instead of
{{{
GISBASE=/usr/lib/grass76 LD_LIBRARY_PATH=/usr/lib/grass76/lib
PYTHONPATH=/usr/lib/grass76/etc/python python -c 'import grass.script' &&
echo 'OK!
}}}
or even
{{{
GISBASE=/usr/lib/grass76 LD_LIBRARY_PATH=$GISBASE/lib
PYTHONPATH=$GISBASE/etc/python python -c 'import grass.script' && echo
'OK!'
}}}
Since you have to know the GISBASE path anyhow to be able to set
LD_LIBRARY_PATH and PYTHONPATH ?
Moritz
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3772#comment:10>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list