[GRASS-dev] [GRASS GIS] #1671: grass/script/setup.py errors

GRASS GIS trac at osgeo.org
Thu Jun 7 09:28:30 PDT 2012


#1671: grass/script/setup.py  errors
-------------------------+--------------------------------------------------
 Reporter:  artegion     |       Owner:  grass-dev@…              
     Type:  defect       |      Status:  new                      
 Priority:  major        |   Milestone:  6.4.3                    
Component:  Python       |     Version:  6.4.2                    
 Keywords:               |    Platform:  All                      
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------
 grass/script/setup.py needs a {{{os.pathsep}}} at this line

 {{{
     ## os.environ['PATH'] += os.path.join(gisbase, 'lib') ##WRONG##
     os.environ['PATH'] += os.pathsep + os.path.join(gisbase, 'lib')
 }}}

 then $GISBASE/extralib and $GISBASE/msys/bin are missed in PATH (for
 windows only)
 {{{
     ## added for winGrass
     if sys.platform.startswith('win'):
          os.environ['PATH'] += os.pathsep + os.path.join(gisbase,
 'extralib')
          os.environ['PATH'] += os.pathsep + os.path.join(gisbase,
 'msys','bin')
 }}}

 of course we need
 {{{import sys}}}
 at the beginning

 Another point ----
 From outside Grass Gis we '''must''' define $GISBASE, $GISRC and add
 $GISBASE/etc/python to sys.path BEFORE import anything from grass
 (I did'nt find anything about this in Programmer's Manual)

 {{{
 ...
 os.environ['GISBASE'] =gisbase

 grass_python_dir= os.path.join(gisbase, 'etc','python')
 if os.path.isdir(os.path.join(grass_python_dir,'grass')):
     sys.path.append(grass_python_dir)
 else:
     raise Exception('etc\python\grass module not found')
 os.environ['GISRC']= 'junk'
 from grass.script import setup
 gisrc= setup.init(os.getenv('GISBASE'),gisdb,location,mapset)

 ...

 os.remove(gisrc)
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1671>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list