Hi,
I get it running (on Linux, winGRASS untested) when setting up the
LD_LIBRARY_PATH at system level:
su
echo "`grass71 --config path`/lib" > /etc/ld.so.conf.d/grass71.conf
ldconfig
exit
# run as normal user:
python python_test_ctypes.py
...
precip_annual@user1
/home/neteler/grassdata/nc_spm_08_grass7
Works.
The issue is that we cannot easily enforce the users to add a file in
/etc/ld.so.conf.d/ since it requires admin rights.
Suggestions?
Markus
import os
import sys
import subprocess
grass7bin = 'grass71'
# FIRST TIME PREPARATION
#sudo echo "`grass71 --config path`/lib" > /etc/ld.so.conf.d/grass71.conf ; ldconfig
####
# query GRASS 7 itself for its GISBASE
# we assume that GRASS GIS' start script is available and in the PATH
startcmd = grass7bin + ' --config path'
p = subprocess.Popen(startcmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode != 0:
print >>sys.stderr, "ERROR: Cannot find GRASS GIS 7 start script (%s)" % startcmd
sys.exit(-1)
gisbase = out.strip('\n')
# Set GISBASE environment variable
os.environ['GISBASE'] = gisbase
gisdbase = os.path.join(os.path.expanduser('~'), 'grassdata')
location = "nc_spm_08_grass7"
mapset = "user1"
sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))
import grass.script as grass
import grass.script.setup as gsetup
gsetup.init(gisbase,
gisdbase, location, mapset)
print grass.gisenv()
grass.message('Raster maps:')
for rast in grass.list_strings(type = 'rast'):
print rast
import grass.lib.gis as gis
print gis.G_location_path()
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev