[GRASS-dev] what do you think about re-organized the /lib/python files?
Pietro
peter.zamb at gmail.com
Wed Dec 5 11:31:59 PST 2012
Hi all!
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?
Best regards.
Pietro
More information about the grass-dev
mailing list