[GRASS-dev] [GRASS GIS] #2424: PyGRASS does not work when GRASS is invoked from outside

GRASS GIS trac at osgeo.org
Sun Oct 5 19:16:18 PDT 2014


#2424: PyGRASS  does not work when GRASS is invoked from outside
------------------------------------------------------+---------------------
 Reporter:  wenzeslaus                                |       Owner:  grass-dev@…              
     Type:  defect                                    |      Status:  new                      
 Priority:  normal                                    |   Milestone:  7.0.0                    
Component:  Python ctypes                             |     Version:  svn-trunk                
 Keywords:  installation, pygrass, temporal, scripts  |    Platform:  MSWindows 8              
      Cpu:  Unspecified                               |  
------------------------------------------------------+---------------------

Comment(by wenzeslaus):

 Another case when I'm hitting this issue is in running tests. There is a
 script which runs the tests. I import form `gunittest` in this test and I
 don't really need much but in `__init__.py` I import some things to
 provide and easy access, so whatever I want to import,
 [source:grass/trunk/lib/python/gunittest/__init__.py __init__.py] gets
 executed, because `pygrass.modules` are used this executes the `pygrass`
 main [source:grass/trunk/lib/python/pygrass/__init__.py __init__.py] which
 imports some PyGRASS things which depend on `ctypes` interface and when
 dynamic libraries are not available, this obviously fails. This is an
 example, how simple you may need dynamic libraries. Temporal framework
 Python API is probably the same case.

 In some cases you can get around this by putting try excepts to the
 library `__init__.py`, as I did for
 [source:grass/trunk/lib/python/gunittest/__init__.py?rev=61489#L20
 gunittest].

 Another way how to improve the situation is to use empty `__init__.py`
 files. We are not doing it now, we are doing almost the opposite and it of
 course has a big advantage as hiding the inner structure of the package.
 On the other hand, from `grass.script` or `grass.pygrass` you usually need
 just a specific part. There is no consensus but there is a lot of people
 thinking that empty `__init__.py` files are the best. You anyway don't
 gain much by hiding the inner structure of the package unless you forbid
 the specific imports in your API doc and we are not doing this. This is of
 course something we should sort out before the release (sorry about that).

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/2424#comment:3>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list