[GRASS-dev] Makefile for an addon using Cython

Laurent C. lrntct at gmail.com
Sun Mar 20 11:16:54 PDT 2016

2016-02-02 17:05 GMT-06:00 Laurent C. <lrntct at gmail.com>:
> 2016-02-01 6:25 GMT-06:00 Pietro <peter.zamb at gmail.com>:
>> Dear Laurent,
>>> I wrote an extension which include a mix of Python and Cyhon files.
>>> What would be the preferable way to make it easy to install with g.extension?
>>> I imagine that it could be easier to distribute the generated C file
>>> along the .pyx file, as it will not require the user to have Cython
>>> installed.
>> Indeed I think that the C file should also tracked.
>>> Which form would take the Makefile in that case? Is there some
>>> examples I could follow?
>> As far as I know this is the first GRASS addon written using Cython,
>> so no examples are available...
>> But you can see other Makefile for python or C addons.
> Makefiles for C and Python are using different default targets.
> I'm wondering if there is any example of a module using both C and Python.
> I've basically no knowledge of neither GNU make or the GRASS
> compilation process, and the on-line documentation recommends using
> boilerplate Makefile for add-ons. I did this with another extension
> written in Python only, but now it's seems a bit more complex to me.
>> Best regards
>> Pietro

Hello again,

I'm trying again to get g.extension working with my module and
encounter some problems. I'm using 'g.extension url=' to try the
installation process from local dir.
I manage to create a Makefile for a module with a single Python file.
Installation works fine in that case. But when I add a python module,
import it from the main file, and add it to ETCFILES in the Makefile,
the installation process does not finish:
Traceback (most recent call last):
  File "/tmp/grass7-laurent-12584/tmp4jPSIT/t.test/scripts/t.test",
line 8, in <module>
    import module_example
ImportError: No module named module_example
make: *** [t.test.tmp.html] Error 1
ERROR: Compilation failed, sorry. Please check above error messages.

Below is the content of the Makefile:

PGM = v.test

ETCFILES = module_example

include $(MODULE_TOPDIR)/include/Make/Script.make
include $(MODULE_TOPDIR)/include/Make/Python.make

default: script

I don't understand what I'm doing wrong

Actually, the same problem appears when trying to install r.agent:
  File "/tmp/grass7-laurent-12584/tmp31YOCD/r.agent/scripts/r.agent.aco",
line 234, in <module>
    import error, grassland, anthill
ImportError: No module named error

but v.class.ml worked fine. I actually copy-pasted the Makefile from there.
But it did only once. Now when I want to install it again, after
un-installing it, it ends up with the same errors:
Traceback (most recent call last):
  File "/tmp/grass7-laurent-12584/tmpEDt2Jh/v.class.ml/scrip
ts/v.class.ml", line 386, in <module>
    from training_extraction import extract_training
ImportError: No module named training_extraction

The behavior of g.extension makes me very confused. Is there something
I'm getting wrong?


More information about the grass-dev mailing list