#NEWLINE# def relative_script( lines ) : #NEWLINE# #INDENT# "Return a script that'll work in a relocatable environment." #NEWLINE# activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this" #NEWLINE# activate_at = None #NEWLINE# for ( idx , line ) in reversed ( list ( enumerate ( lines ) ) ) : #NEWLINE# #INDENT# if ( line . split ( ) [ : 3 ] == [ 'from' , '__future__' , 'import' ] ) : #NEWLINE# #INDENT# activate_at = ( idx + 1 ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( activate_at is None ) : #NEWLINE# #INDENT# activate_at = 1 #NEWLINE# #UNINDENT# return ( ( lines [ : activate_at ] + [ '' , activate , '' ] ) + idx [ activate_at : ] )