<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import sys <EOL> import os <EOL> import glob <EOL> import optparse <EOL> from os . path import exists , join , abspath , basename <EOL> from pipes import quote <EOL> TMPDIR = '<STR_LIT>' <EOL> def system ( cmd , noisy = True ) : <EOL> if noisy : <EOL> print ( cmd ) <EOL> res = os . system ( cmd ) <EOL> if res : <EOL> sys . exit ( '<STR_LIT>' % ( cmd , res ) ) <EOL> def makedist ( * args , ** kwargs ) : <EOL> cwd = os . getcwd ( ) <EOL> try : <EOL> return _makedist ( * args , ** kwargs ) <EOL> finally : <EOL> os . chdir ( cwd ) <EOL> def _makedist ( version = None , dest = None ) : <EOL> assert exists ( '<STR_LIT>' ) , '<STR_LIT>' <EOL> basedir = abspath ( os . getcwd ( ) ) <EOL> version = version or '<STR_LIT>' <EOL> set_version_command = '<STR_LIT>' % version <EOL> os . chdir ( '<STR_LIT>' ) <EOL> system ( '<STR_LIT>' + TMPDIR ) <EOL> os . mkdir ( TMPDIR ) <EOL> os . chdir ( TMPDIR ) <EOL> system ( '<STR_LIT>' % basedir ) <EOL> directory = os . listdir ( '<STR_LIT:.>' ) <EOL> assert len ( directory ) == <NUM_LIT:1> , directory <EOL> os . chdir ( directory [ <NUM_LIT:0> ] ) <EOL> system ( '<STR_LIT>' ) <EOL> system ( set_version_command ) <EOL> system ( '<STR_LIT>' , noisy = False ) <EOL> system ( '<STR_LIT>' ) <EOL> dist_filename = glob . glob ( '<STR_LIT>' ) <EOL> assert len ( dist_filename ) == <NUM_LIT:1> , dist_filename <EOL> dist_path = abspath ( dist_filename [ <NUM_LIT:0> ] ) <EOL> dist_filename = basename ( dist_path ) <EOL> if dest : <EOL> if os . path . isdir ( dest ) : <EOL> dest = join ( dest , dist_filename ) <EOL> else : <EOL> if not exists ( join ( basedir , '<STR_LIT>' ) ) : <EOL> os . mkdir ( join ( basedir , '<STR_LIT>' ) ) <EOL> dest = join ( basedir , '<STR_LIT>' , dist_filename ) <EOL> copy ( dist_path , dest ) <EOL> return dist_path <EOL> def main ( ) : <EOL> parser = optparse . OptionParser ( ) <EOL> parser . add_option ( '<STR_LIT>' ) <EOL> parser . add_option ( '<STR_LIT>' ) <EOL> options , args = parser . parse_args ( ) <EOL> assert not args , '<STR_LIT>' <EOL> return makedist ( options . version , dest = options . dest ) <EOL> def copy ( source , dest ) : <EOL> system ( '<STR_LIT>' % ( quote ( source ) , quote ( dest ) ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
