[GRASS-user] GRASSBIN environment variable

Stefan Blumentrath Stefan.Blumentrath at nina.no
Fri Aug 16 01:00:08 PDT 2019


Hi Alex,

Yes indeed. Would be nice to avoid that.

There is actually an open pull request about it:
https://github.com/zarch/grass-session/pull/12/files
However, I guess a completely version independent solution would be preferable...

With Python 3 shutil.which() will be available also on Windows, however, in OSGeo4W, a version independent "grass.bat" does not seem to be available.
So, currently, for Windows, it is inevitable to include versions. Could be done like this:

def get_grassbin():
    """Find GRASS GIS startup binary"""
    from shutil import which

    grassbin = which('grass')
    if not grassbin:
        for v in range(71, 80):
            grassbin_version = which('grass{}'.format(v))
            if grassbin_version:
                grassbin = grassbin_version

    return grassbin
get_grassbin()

Not sure when the GRASSBIN variable is set, I guess during startup of GRASS. So when you run grass-session from within GRASS the variable should be set (just guessing though)...

Cheers
Stefan

From: grass-user <grass-user-bounces at lists.osgeo.org> On Behalf Of Moody, Alex
Sent: fredag 16. august 2019 01:00
To: grass-user at lists.osgeo.org
Subject: [GRASS-user] GRASSBIN environment variable

Hi all - I am trying out the grass-session package for the first time and am having issues with the GRASSBIN environment variable. It looks like the grass-session I was able to download references grass75svn.bat. I'm onto grass76.

I was able to get around this in a python session with os.environ['GRASSBIN']=D:\<mypath>\grass76.bat, but it'd be nice to not have to do that.

If I run "set GRASS" from the command line, I see that GRASSBIN=D:\<mypath>\grass75svn.bat even GRASS_VERSION=7.6.1

Where is the GRASSBIN variable set? I've been looking around and can't seem to find it.

Cheers,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190816/090bcb7c/attachment-0001.html>


More information about the grass-user mailing list