[GRASS-dev] what do you think about re-organized the /lib/python files?
Sören Gebbert
soerengebbert at googlemail.com
Thu Dec 6 02:26:07 PST 2012
Hi Pietro,
i definitely like the idea. The current layout has historical reasons.
IMHO there is no need to keep it.
But care must be taken so that existing Python scripts will not break.
Best regards
Soeren
2012/12/5 Pietro <peter.zamb at gmail.com>:
> 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
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
More information about the grass-dev
mailing list