Skip to content

Commit 5acbd05

Browse files
committed
fix GUI dirs
1 parent ce69418 commit 5acbd05

File tree

18 files changed

+88
-61
lines changed

18 files changed

+88
-61
lines changed

display/d.mon/start.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@ char *start_wx(const char *name, const char *element, int width, int height,
115115
mapfile = (char *)G_malloc(GPATH_MAX);
116116
mapfile[0] = '\0';
117117

118-
snprintf(progname, sizeof(progname), "%s/gui/wxpython/mapdisp/main.py",
119-
G_gisbase());
118+
const char *wxdir = getenv("GRASS_GUIWXDIR");
119+
if (!wxdir)
120+
G_fatal_error(_("Incomplete GRASS session: Variable '%s' not set"),
121+
"GRASS_GUIWXDIR");
122+
123+
snprintf(progname, sizeof(progname), "%s/mapdisp/main.py", wxdir);
120124
snprintf(str_width, sizeof(str_width), "%d", width);
121125
snprintf(str_height, sizeof(str_height), "%d", height);
122126

doc/examples/gui/wxpython/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# this enables to run application standalone (> python example/frame.py )
2424
if __name__ == "__main__":
25-
sys.path.append(os.path.join(os.environ["GISBASE"], "etc", "gui", "wxpython"))
25+
sys.path.append(os.environ["GRASS_GUIWXDIR"])
2626

2727
# i18n is taken care of in the grass library code.
2828
# So we need to import it before any of the GUI code.

doc/examples/gui/wxpython/g.gui.example.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import grass.script.core as gcore
3939

4040
if __name__ == "__main__":
41-
wxbase = os.path.join(os.getenv("GISBASE"), "etc", "gui", "wxpython")
41+
wxbase = os.environ["GRASS_GUIWXDIR"]
4242
if wxbase not in sys.path:
4343
sys.path.append(wxbase)
4444

general/g.gui/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ int main(int argc, char *argv[])
104104
exit(EXIT_SUCCESS);
105105
}
106106

107-
snprintf(progname, sizeof(progname), "%s/gui/wxpython/wxgui.py",
108-
G_gisbase());
107+
const char *wxdir = getenv("GRASS_GUIWXDIR");
108+
if (!wxdir)
109+
G_fatal_error(_("Incomplete GRASS session: Variable '%s' not set"),
110+
"GRASS_GUIWXDIR");
111+
112+
snprintf(progname, sizeof(progname), "%s/wxgui.py", wxdir);
109113
if (access(progname, F_OK) == -1)
110114
G_fatal_error(_("Your installation doesn't include GUI, exiting."));
111115

general/g.mapsets/main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,14 @@ int main(int argc, char *argv[])
215215
if (opt.dialog->answer) {
216216
if (opt.mapset->answer)
217217
G_warning(_("Option <%s> ignored"), opt.mapset->key);
218-
snprintf(path_buf, sizeof(path_buf),
219-
"%s/gui/wxpython/modules/mapsets_picker.py", G_gisbase());
218+
219+
const char *wxdir = getenv("GRASS_GUIWXDIR");
220+
if (!wxdir)
221+
G_fatal_error(_("Incomplete GRASS session: Variable '%s' not set"),
222+
"GRASS_GUIWXDIR");
223+
224+
snprintf(path_buf, sizeof(path_buf), "%s/modules/mapsets_picker.py",
225+
wxdir);
220226
G_spawn(getenv("GRASS_PYTHON"), "mapsets_picker.py", path_buf, NULL);
221227
exit(EXIT_SUCCESS);
222228
}

gui/wxpython/core/globalvar.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
from pathlib import Path
2727

2828
# path to python scripts
29-
ETCDIR = os.path.join(os.getenv("GISBASE"), "etc")
30-
GUIDIR = os.path.join(os.getenv("GISBASE"), "gui")
31-
WXGUIDIR = os.path.join(GUIDIR, "wxpython")
32-
ICONDIR = os.path.join(GUIDIR, "icons")
33-
IMGDIR = os.path.join(GUIDIR, "images")
29+
PYDIR = os.getenv("GRASS_PYDIR")
30+
ETCDIR = os.path.join(os.getenv("GRASS_SHARE_DIR"), "etc")
31+
WXGUIDIR = os.getenv("GRASS_GUIWXDIR")
32+
ICONDIR = os.path.join(os.getenv("GRASS_GUIRESDIR"), "icons")
33+
IMGDIR = os.path.join(os.getenv("GRASS_GUIRESDIR"), "images")
3434
SYMBDIR = os.path.join(IMGDIR, "symbols")
3535

3636
WXPY3_MIN_VERSION = [4, 0, 0, 0]
@@ -249,7 +249,7 @@ def UpdateGRASSAddOnCommands(eList=None):
249249
gtk3 = "gtk3" in wx.PlatformInfo
250250

251251
# Add GUIDIR/scripts into path
252-
os.environ["PATH"] = os.path.join(GUIDIR, "scripts") + os.pathsep + os.environ["PATH"]
252+
os.environ["PATH"] = os.environ["GRASS_GUISCRIPTDIR"] + os.pathsep + os.environ["PATH"]
253253

254254
ignoredCmdPattern = (
255255
r"^d\..*|^r[3]?\.mapcalc$|^i.group$|^r.import$|"

gui/wxpython/core/toolboxes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# if this will become part of grass Python library or module, this should be
3232
# parametrized, so we will get rid of the definition here
3333
# (GUI will use its definition and build also its own)
34-
WXGUIDIR = os.path.join(os.getenv("GISBASE"), "gui", "wxpython")
34+
WXGUIDIR = os.environ["GRASS_GUIWXDIR"]
3535

3636

3737
# this could be placed to functions

gui/wxpython/image2target/ii2t_gis_set.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ def __init__(self, parent=None, id=wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE):
8888
# image
8989
try:
9090
if os.getenv("ISISROOT"):
91-
name = os.path.join(
92-
globalvar.GUIDIR, "images", "startup_banner_isis.png"
93-
)
91+
name = os.path.join(globalvar.IMGDIR, "startup_banner_isis.png")
9492
else:
95-
name = os.path.join(globalvar.GUIDIR, "images", "startup_banner.png")
93+
name = os.path.join(globalvar.IMGDIR, "startup_banner.png")
9694
self.hbitmap = wx.StaticBitmap(
9795
self.panel, wx.ID_ANY, wx.Bitmap(name=name, type=wx.BITMAP_TYPE_PNG)
9896
)

gui/wxpython/lmgr/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
except ImportError:
3636
import wx.lib.flatnotebook as FN
3737

38-
if os.path.join(globalvar.ETCDIR, "python") not in sys.path:
39-
sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
38+
if globalvar.PYDIR not in sys.path:
39+
sys.path.append(globalvar.PYDIR)
4040

4141
from grass.script import core as grass
4242
from grass.script.utils import decode

gui/wxpython/main_window/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
except ImportError:
4242
import wx.lib.flatnotebook as FN
4343

44-
if os.path.join(globalvar.ETCDIR, "python") not in sys.path:
45-
sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
44+
if globalvar.PYDIR not in sys.path:
45+
sys.path.append(globalvar.PYDIR)
4646

4747
from grass.script import core as grass
4848
from grass.script.utils import decode

gui/wxpython/psmap/dialogs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,13 +2203,13 @@ def __init__(self, parent, id, vectors, tmpSettings):
22032203
self.currLayer = self.vPropertiesDict["layer"]
22042204

22052205
# path to symbols, patterns
2206-
gisbase = os.getenv("GISBASE")
2207-
self.symbolPath = os.path.join(gisbase, "etc", "symbol")
2206+
g_share_dir = os.getenv("GRASS_SHARE_DIR")
2207+
self.symbolPath = os.path.join(g_share_dir, "etc", "symbol")
22082208
self.symbols = []
22092209
for dir in Path(self.symbolPath).iterdir():
22102210
for symbol in Path(self.symbolPath).joinpath(dir.name).iterdir():
22112211
self.symbols.append(os.path.join(dir.name, symbol.name))
2212-
self.patternPath = os.path.join(gisbase, "etc", "paint", "patterns")
2212+
self.patternPath = os.path.join(g_share_dir, "etc", "paint", "patterns")
22132213

22142214
# notebook
22152215
notebook = Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
@@ -6193,8 +6193,8 @@ def _newObject(self):
61936193
return NorthArrow(self.id, self.instruction, env=self.env)
61946194

61956195
def _getImageDirectory(self):
6196-
gisbase = os.getenv("GISBASE")
6197-
return os.path.join(gisbase, "etc", "paint", "decorations")
6196+
g_share_dir = os.getenv("GRASS_SHARE_DIR")
6197+
return os.path.join(g_share_dir, "etc", "paint", "decorations")
61986198

61996199
def _addConvergence(self, panel, gridBagSizer):
62006200
convergence = Button(parent=panel, id=wx.ID_ANY, label=_("Compute convergence"))

include/Make/Rules.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ run_grass = \
4747
GISBASE=$(RUN_GISBASE) \
4848
GRASS_SHARE_DIR=$(RUN_GISBASE) \
4949
GRASS_LOCALEDIR=$(RUN_GISBASE)/locale \
50+
GRASS_GUIWXDIR=$(RUN_GISBASE)/gui/wxpython \
5051
PATH="$(ARCH_DISTDIR)/bin:$(GISBASE)/bin:$(GISBASE)/scripts:$$PATH" \
5152
PYTHONPATH="$(GRASS_PYTHONPATH)" \
5253
$(LD_LIBRARY_PATH_VAR)="$(BIN):$(GISBASE)/bin:$(GISBASE)/scripts:$(ARCH_LIBDIR):$(BASE_LIBDIR):$($(LD_LIBRARY_PATH_VAR))" \

lib/gis/is.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int test_path_file(const char *path, const char *file)
4949

5050
int G_is_gisbase(const char *path)
5151
{
52-
return test_path_file(path, "etc/element_list");
52+
return test_path_file(path, "etc/echo");
5353
}
5454

5555
/**

lib/gis/parser.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,12 @@ int module_gui_wx(void)
988988
if (!st->pgm_path)
989989
G_fatal_error(_("Unable to determine program name"));
990990

991-
snprintf(script, GPATH_MAX, "%s/gui/wxpython/gui_core/forms.py",
992-
getenv("GISBASE"));
991+
const char *wxdir = getenv("GRASS_GUIWXDIR");
992+
if (!wxdir)
993+
G_fatal_error(_("Incomplete GRASS session: Variable '%s' not set"),
994+
"GRASS_GUIWXDIR");
995+
996+
snprintf(script, GPATH_MAX, "%s/gui_core/forms.py", wxdir);
993997
if (access(script, F_OK) != -1)
994998
G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), script,
995999
G_recreate_command_original_path(), NULL);

lib/init/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ endif
7272
-e 's#@GISBASE_INSTALL_PATH@#$(RUN_GISBASE)#' \
7373
-e 's#@GRASS_SHARE_DIR@#$(RUN_GISBASE)#' \
7474
-e 's#@GRASS_LOCALE@#$(RUN_GISBASE)/locale#' \
75+
-e 's#@GRASS_PYDIR@#$(RUN_GISBASE)/etc/python#' \
76+
-e 's#@GRASS_GUIWXDIR@#$(RUN_GISBASE)/gui/wxpython#' \
77+
-e 's#@GRASS_GUISCRIPTDIR@#$(RUN_GISBASE)/gui/scripts#' \
78+
-e 's#@GRASS_GUIRESDIR@#$(RUN_GISBASE)/gui#' \
7579
-e 's#@GRASS_VERSION_NUMBER@#$(GRASS_VERSION_NUMBER)#' \
7680
-e 's#@GRASS_VERSION_MAJOR@#$(GRASS_VERSION_MAJOR)#' \
7781
-e 's#@GRASS_VERSION_MINOR@#$(GRASS_VERSION_MINOR)#' \

lib/init/grass.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,30 @@
113113
GRASS_LOCALEDIR = os.path.normpath("@GRASS_LOCALE@")
114114
os.environ["GRASS_LOCALEDIR"] = GRASS_LOCALEDIR
115115

116+
if "GRASS_PYDIR" in os.environ and len(os.getenv("GRASS_PYDIR")) > 0:
117+
GRASS_PYDIR = os.path.normpath(os.environ["GRASS_PYDIR"])
118+
else:
119+
GRASS_PYDIR = os.path.normpath("@GRASS_PYDIR@")
120+
os.environ["GRASS_PYDIR"] = GRASS_PYDIR
121+
122+
if "GRASS_GUIWXDIR" in os.environ and len(os.getenv("GRASS_GUIWXDIR")) > 0:
123+
GRASS_GUIWXDIR = os.path.normpath(os.environ["GRASS_GUIWXDIR"])
124+
else:
125+
GRASS_GUIWXDIR = os.path.normpath("@GRASS_GUIWXDIR@")
126+
os.environ["GRASS_GUIWXDIR"] = GRASS_GUIWXDIR
127+
128+
if "GRASS_GUISCRIPTDIR" in os.environ and len(os.getenv("GRASS_GUISCRIPTDIR")) > 0:
129+
GRASS_GUISCRIPTDIR = os.path.normpath(os.environ["GRASS_GUISCRIPTDIR"])
130+
else:
131+
GRASS_GUISCRIPTDIR = os.path.normpath("@GRASS_GUISCRIPTDIR@")
132+
os.environ["GRASS_GUISCRIPTDIR"] = GRASS_GUISCRIPTDIR
133+
134+
if "GRASS_GUIRESDIR" in os.environ and len(os.getenv("GRASS_GUIRESDIR")) > 0:
135+
GRASS_GUIRESDIR = os.path.normpath(os.environ["GRASS_GUIRESDIR"])
136+
else:
137+
GRASS_GUIRESDIR = os.path.normpath("@GRASS_GUIRESDIR@")
138+
os.environ["GRASS_GUIRESDIR"] = GRASS_GUIRESDIR
139+
116140
CMD_NAME = "@START_UP@"
117141
GRASS_VERSION = "@GRASS_VERSION_NUMBER@"
118142
GRASS_VERSION_MAJOR = "@GRASS_VERSION_MAJOR@"

python/grass/docs/conf.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,40 @@
1919
# If extensions (or modules to document with autodoc) are in another directory,
2020
# add these directories to sys.path here. If the directory is relative to the
2121
# documentation root, use os.path.abspath to make it absolute, like shown here.
22-
if not os.getenv("GISBASE"):
23-
sys.exit("GISBASE not defined")
24-
sys.path.insert(
25-
0, os.path.abspath(os.path.join(os.environ["GISBASE"], "etc", "python", "grass"))
26-
)
22+
if not os.getenv("GRASS_PYDIR"):
23+
sys.exit("GRASS_PYDIR not defined")
24+
sys.path.insert(0, os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass")))
2725
sys.path.insert(
2826
0,
29-
os.path.abspath(
30-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "ctypes")
31-
),
27+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "ctypes")),
3228
)
3329
sys.path.insert(
3430
0,
35-
os.path.abspath(
36-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "exceptions")
37-
),
31+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "exceptions")),
3832
)
3933
sys.path.insert(
4034
0,
41-
os.path.abspath(
42-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "gunittest")
43-
),
35+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "gunittest")),
4436
)
4537
sys.path.insert(
4638
0,
47-
os.path.abspath(
48-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "imaging")
49-
),
39+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "imaging")),
5040
)
5141
sys.path.insert(
5242
0,
53-
os.path.abspath(
54-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "pydispatch")
55-
),
43+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "pydispatch")),
5644
)
5745
sys.path.insert(
5846
0,
59-
os.path.abspath(
60-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "pygrass")
61-
),
47+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "pygrass")),
6248
)
6349
sys.path.insert(
6450
0,
65-
os.path.abspath(
66-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "script")
67-
),
51+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "script")),
6852
)
6953
sys.path.insert(
7054
0,
71-
os.path.abspath(
72-
os.path.join(os.environ["GISBASE"], "etc", "python", "grass", "temporal")
73-
),
55+
os.path.abspath(os.path.join(os.environ["GRASS_PYDIR"], "grass", "temporal")),
7456
)
7557

7658
from grass.script import core # noqa: E402

python/grass/script/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def write_gisrc(dbase, location, mapset):
107107

108108
def set_gui_path():
109109
"""Insert wxPython GRASS path to sys.path."""
110-
gui_path = os.path.join(os.environ["GISBASE"], "gui", "wxpython")
110+
gui_path = os.environ["GRASS_GUIWXDIR"]
111111
if gui_path and gui_path not in sys.path:
112112
sys.path.insert(0, gui_path)
113113

0 commit comments

Comments
 (0)