[GRASS-dev] what do you think about re-organized the /lib/python files?

Luca Delucchi lucadeluge at gmail.com
Wed Dec 5 15:46:43 PST 2012


2012/12/5 Pietro <peter.zamb at gmail.com>:
> Hi all!
>

Hi Pietro

> What do you think of:
>
>
>
> 1) create a new directory /lib/python/script and move (the following
> modules: array.py core.py db.py raster.py raster3d.py setup.py.sed
> task.py vector.py) inside.
> in this way the struct in /lib/python would be:
>
> /lib/python
> ├── ctypes/
> ├── pygrass/
> ├── script/
> ├── temporal/
> ├── Makefile
> ├── __init__.py
> └── pythonlib.dox
>
> For me it's clearer and more consistent with other python modules.
>
>
>
> 2) change the module setup.py, that at the moment is generated during
> the compilation (setup.py.sed => setup.py), to use something like:
>
> {{{
> 27a28,31
>> LD_LIB_OS = {'win': 'PATH', #Windows
>>              'dar': 'LD_LIBRARY_PATH', #Mac OS X
>>              }
>>
> 45,48c49,53
> <     # define LD_LIBRARY_PATH
> <     if '@LD_LIBRARY_PATH_VAR@' not in os.environ:
> <         os.environ['@LD_LIBRARY_PATH_VAR@'] = ''
> <     os.environ['@LD_LIBRARY_PATH_VAR@'] += os.pathsep +
> os.path.join(gisbase, 'lib')
> ---
>>
>>     # define LD_LIBRARY_PATH default is: 'LD_LIBRARY_PATH'
>>     ld_lib = LD_LIB_OS.get(sys.platform[:3], 'LD_LIBRARY_PATH')
>>     os.environ[ld_lib] = os.environ.get(ld_lib, '') + os.pathsep +\
>>                          os.path.join(gisbase, 'lib')
> }}}
>
>
>
> 3) change the __init__.py contained in /lib/python, at the moment we
> have this behaviour:
>
>>>> import grass
>>>> grass.script.core.run_command('r.info', map='elevation')
> Traceback (most recent call last):
>   File "<ipython-input-5-c3c1814cb046>", line 1, in <module>
>     grass.script.core
> AttributeError: 'module' object has no attribute 'script'
>>>> dir(grass)
> ['__all__', '__builtins__', '__doc__', '__file__', '__name__',
> '__package__', '__path__', 'os']
>>>> grass.__all__
> ['script', 'temporal', 'lib']
>
>
>
> I would prefer something more explicit like:
>
>>>> import grass
>>>> dir(grass)
> ['__all__', '__builtins__', '__doc__', '__file__', '__name__',
> '__package__', '__path__', 'lib', 'os', 'pygrass', 'script',
> 'temporal']
>
>
> What do you think?
>

We already spoke about this and I really like this solution.
Maybe you should provide a patch so everybody can test it?

> Best regards.
>
> Pietro

-- 
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org


More information about the grass-dev mailing list