<s> import sys , os , os . path <EOL> progpath = sys . argv [ <NUM_LIT:0> ] <EOL> packagedir = os . path . abspath ( os . path . dirname ( progpath ) ) <EOL> packagename = os . path . basename ( packagedir ) <EOL> bindir = os . path . join ( packagedir , '<STR_LIT>' ) <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> bindir = os . path . join ( bindir , '<STR_LIT:win32>' ) <EOL> rootdir = os . path . dirname ( packagedir ) <EOL> def prepend_path ( name , value ) : <EOL> sep = os . path . pathsep <EOL> curpath = os . environ . get ( name , '<STR_LIT>' ) <EOL> newpath = [ value ] + [ x for x in curpath . split ( sep ) if x and x != value ] <EOL> return setenv ( name , sep . join ( newpath ) ) <EOL> def setenv ( name , value ) : <EOL> shell = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> comspec = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if shell . endswith ( '<STR_LIT>' ) : <EOL> cmd = '<STR_LIT>' % ( name , value ) <EOL> elif shell . endswith ( '<STR_LIT>' ) : <EOL> cmd = '<STR_LIT>' % ( name , value , name ) <EOL> elif comspec . endswith ( '<STR_LIT>' ) : <EOL> cmd = '<STR_LIT>' % ( name , value ) <EOL> else : <EOL> assert False , '<STR_LIT>' <EOL> return cmd <EOL> print prepend_path ( '<STR_LIT>' , bindir ) <EOL> print prepend_path ( '<STR_LIT>' , rootdir ) </s>
