[GRASS-dev] Handling of Python scripts on MS Windows

Glynn Clements glynn at gclements.plus.com
Tue Apr 8 19:07:43 PDT 2014


Vaclav Petras wrote:

> I basically agree with user expectations you stated. But I would like to
> note that recently, I met several users which wanted and expected that
> GRASS script will run outside GRASS without any special environment setup
> in the script itself. Perhaps, ArcGIS sets the environment, so this might
> be the reason they expect the same from GRASS. I wonder if we can make
> setting the environment in Python easier.

Windows' environment handling mimics that of Unix: a process can set
its own environment, which is inherited by child processes, or it can
explicitly set the environment of a child process at creation time.

But you can't write a program which sets the environment for the shell
(or other program) from which it was invoked, for the benefit of
subsequent child processes started from the same shell.

Packages which include command-line programs (e.g. compilers)
typically either modify the environment variables (e.g. PATH) via the
registry[1], or provide a .bat/.cmd file which must be run to set up
the environment for a particular shell.

We could certainly reduce the number of environment variables
involved, e.g. by having G_gisinit() check for missing variables and
initialising them from settings in the registry. Even GISRC could fall
back to e.g. %APPDATA%\GRASS\gisrc.

Supporting multiple installed versions and/or multiple concurrent
sessions would be marginally more complex. But then many Windows
applications entirely prohibit doing either of those.

[1] HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
for the system-wide settings and HKCU\Environment for the per-user
settings.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list