[GRASS-dev] python scripts in grass6
Glynn Clements
glynn at gclements.plus.com
Sun Jul 5 18:04:30 EDT 2009
Martin Landa wrote:
> currently in GRASS 6 PGM variable must be set including python file
> extension, in GRASS 7 not, e.g.
>
> PGM=v.krige.py in GRASS6
> PGM=v.krige in GRASS7
>
> Would be possible to change building system in GRASS 6 to unify it with GRASS 7.
GRASS 7 now *only* allows Python scripts, so I don't think you want to
unify it quite that far.
The main issue is that, on Windows, make needs to know whether it's
supposed to be creating $(SCRIPTDIR)/$(PGM).py or
$(SCRIPTDIR)/$(PGM).sh. Once you know what the target is, it's easy
enought to create it.
The problem doesn't exist on Unix, as you always want to create
$(SCRIPTDIR)/$(PGM); you can just provide multiple rules to create it
from either %.py or %, and make will use whichever is available.
Actually, if you use $(BIN)/$(PGM).bat as the ultimate target, you can
then add two rules to create that from either $(SCRIPTDIR)/$(PGM).py
or $(SCRIPTDIR)/$(PGM).sh, i.e.:
ifdef MINGW
script: $(BIN)/$(PGM).bat
else
script: $(SCRIPTDIR)/$(PGM)
endif
$(BIN)/%.bat: $(SCRIPTDIR)/%.py
# generate .bat file to run .py file
$(BIN)/%.bat: $(SCRIPTDIR)/%.sh
# generate .bat file to run .sh file
$(SCRIPTDIR)/%.py: %.py
$(INSTALL) $< $@
$(SCRIPTDIR)/%.sh: %
$(INSTALL) $< $@
$(SCRIPTDIR)/%: %.py
$(INSTALL) $< $@
$(SCRIPTDIR)/%: %
$(INSTALL) $< $@
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list