~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/python/setup.py.sed

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""!@package grass.script.setup
2
 
 
3
 
@brief GRASS Python scripting module (setup)
4
 
 
5
 
Setup functions to be used in Python scripts.
6
 
 
7
 
Usage:
8
 
 
9
 
@code
10
 
from grass.script import setup as grass
11
 
 
12
 
grass.init()
13
 
...
14
 
@endcode
15
 
 
16
 
(C) 2010-2012 by the GRASS Development Team
17
 
This program is free software under the GNU General Public
18
 
License (>=v2). Read the file COPYING that comes with GRASS
19
 
for details.
20
 
 
21
 
@author Martin Landa <landa.martin gmail.com>
22
 
"""
23
 
 
24
 
import os
25
 
import sys
26
 
import tempfile as tmpfile
27
 
 
28
 
def init(gisbase, dbase = '', location = 'demolocation', mapset = 'PERMANENT'):
29
 
    """!Initialize system variables to run scripts without starting
30
 
    GRASS explicitly.
31
 
 
32
 
    User is resposible to delete gisrc file.
33
 
 
34
 
    @param gisbase path to GRASS installation
35
 
    @param dbase   path to GRASS database (default: '')
36
 
    @param location location name (default: 'demolocation')
37
 
    @param mapset   mapset within given location (default: 'PERMANENT')
38
 
    @return path to gisrc file
39
 
    """
40
 
    # define PATH
41
 
    os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'bin')
42
 
    os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'scripts')
43
 
    if sys.platform.startswith('win'): # added for winGRASS
44
 
         os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'extralib')
45
 
         os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'msys', 'bin')
46
 
    # define LD_LIBRARY_PATH
47
 
    if '@LD_LIBRARY_PATH_VAR@' not in os.environ:
48
 
        os.environ['@LD_LIBRARY_PATH_VAR@'] = ''
49
 
    os.environ['@LD_LIBRARY_PATH_VAR@'] += os.pathsep + os.path.join(gisbase, 'lib')
50
 
    
51
 
    os.environ['GIS_LOCK'] = str(os.getpid())
52
 
    
53
 
    # Set PYTHONPATH to find GRASS Python modules
54
 
    path = os.getenv('PYTHONPATH')
55
 
    dir  = os.path.join(gisbase, 'etc', 'python')
56
 
    if path:
57
 
        path = dir + os.pathsep + path
58
 
    else:
59
 
        path = dir
60
 
    os.environ['PYTHONPATH'] = path
61
 
    
62
 
    if not dbase:
63
 
        dbase = gisbase
64
 
    
65
 
    fd, gisrc = tmpfile.mkstemp()
66
 
    os.environ['GISRC'] = gisrc
67
 
    os.write(fd, "GISDBASE: %s\n" % dbase)
68
 
    os.write(fd, "LOCATION_NAME: %s\n" % location)
69
 
    os.write(fd, "MAPSET: %s\n" % mapset)
70
 
    os.close(fd)
71
 
    
72
 
    return gisrc