[GRASS-dev] "Max OS 10.8: g.gui and DISPLAY"

Hi,

Anna and I are trying to compile GRASS 7 on Mac OS 10.8. Although there were some problems we were able to compile it.

But than we were not able to start GRASS because initialization ended with the error message about missing X Window system. This comes from init/grass.py where it checks for DISPLAY variable. The variable is not set. Do we need it to test it for GRASS7 and Mac OS? Setting to any value (e.g., export DISPLAY=0) solved the problem.

The second error appears when we try to launch GUI from command line using g.gui (i.e., the error does not happen during GRASS launch):

wxgui.py: posix_spawn: /Users/…wxpython/wxgui.py2.7: No such file or directory

Changing the second parameter of G_spawn_ex to a ‘python’ instead of a ‘python source’ solved the problem:

Index: g.gui/main.c

— g.gui/main.c (revision 57519)
+++ g.gui/main.c (working copy)
@@ -113,12 +113,13 @@

if (strcmp(type->answer, “wxpython”) == 0) {
sprintf(progname, “%s/etc/gui/wxpython/wxgui.py”, G_gisbase());
if (rc_file->answer) {

  • G_spawn_ex(getenv(“GRASS_PYTHON”), progname, progname,
  • G_spawn_ex(getenv(“GRASS_PYTHON”), getenv(“GRASS_PYTHON”), progname,
    “–workspace”, rc_file->answer, SF_BACKGROUND, NULL);
    }
    else {
  • G_spawn_ex(getenv(“GRASS_PYTHON”), progname, progname,
  • G_spawn_ex(getenv(“GRASS_PYTHON”), getenv(“GRASS_PYTHON”), progname,
    SF_BACKGROUND, NULL);
    }
    }

We don’t understand the code in spawn.c and there are even no comments… so we are lost.

Anna and Vaclav

Vaclav Petras wrote:

Anna and I are trying to compile GRASS 7 on Mac OS 10.8. Although there
were some problems we were able to compile it.

But than we were not able to start GRASS because initialization ended with
the error message about missing X Window system. This comes from
init/grass.py where it checks for DISPLAY variable. The variable is not
set. Do we need it to test it for GRASS7 and Mac OS? Setting to any value
(e.g., export DISPLAY=0) solved the problem.

That's a bug in grass.py:

    if os.getenv('DISPLAY') or windows:

That should probably be:

    if os.getenv('DISPLAY') or windows or macosx:

The second error appears when we try to launch GUI from command line using
g.gui (i.e., the error does not happen during GRASS launch):

wxgui.py: posix_spawn: /Users/...wxpython/wxgui.py2.7: No such file or
directory

Changing the second parameter of G_spawn_ex to a 'python' instead of a
'python source' solved the problem:

That looks fine. When executing a script from the shell, argv[0] is
the path to the interpreter rather than that of the script.

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

Thanks Glynn for checking this.

···

On Wed, Aug 28, 2013 at 4:47 PM, Glynn Clements <glynn@gclements.plus.com> wrote:

Vaclav Petras wrote:

Anna and I are trying to compile GRASS 7 on Mac OS 10.8. Although there
were some problems we were able to compile it.

But than we were not able to start GRASS because initialization ended with
the error message about missing X Window system. This comes from
init/grass.py where it checks for DISPLAY variable. The variable is not
set. Do we need it to test it for GRASS7 and Mac OS? Setting to any value
(e.g., export DISPLAY=0) solved the problem.

That’s a bug in grass.py:

if os.getenv(‘DISPLAY’) or windows:

That should probably be:

if os.getenv(‘DISPLAY’) or windows or macosx:

Done in r57536.

https://trac.osgeo.org/grass/changeset/57536

The second error appears when we try to launch GUI from command line using
g.gui (i.e., the error does not happen during GRASS launch):

wxgui.py: posix_spawn: /Users/…wxpython/wxgui.py2.7: No such file or
directory

Changing the second parameter of G_spawn_ex to a ‘python’ instead of a
‘python source’ solved the problem:

That looks fine. When executing a script from the shell, argv[0] is
the path to the interpreter rather than that of the script.

Done in r57537.

https://trac.osgeo.org/grass/changeset/57537


Glynn Clements <glynn@gclements.plus.com>