#NEWLINE# def main( ) : #NEWLINE# #INDENT# p = OptionParser ( usage = __doc__ . strip ( ) ) #NEWLINE# p . add_option ( '--clean' , '-c' , action = 'store_true' , help = 'clean source directory' ) #NEWLINE# ( options , args ) = p . parse_args ( ) #NEWLINE# if ( not args ) : #NEWLINE# #INDENT# p . error ( 'no submodules given' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dirs = [ ( 'numpy/%s' % x ) for x in map ( os . path . basename , args ) ] #NEWLINE# #UNINDENT# if ( not os . path . isdir ( TEMP ) ) : #NEWLINE# #INDENT# os . makedirs ( TEMP ) #NEWLINE# #UNINDENT# dummy_files = { #NEWLINE# #INDENT# '__init__.py' : 'from numpy.version import version as __version__' , #NEWLINE# 'version.py' : 'version = "1.4.0.dev"' , #NEWLINE# #UNINDENT# } #NEWLINE# for ( fn , content ) in dummy_files . items ( ) : #NEWLINE# #INDENT# fn = os . path . join ( TEMP , 'numpy' , fn ) #NEWLINE# if ( not os . path . isfile ( fn ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# os . makedirs ( os . path . dirname ( fn ) ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# f = open ( fn , 'wb+' ) #NEWLINE# f . write ( content . encode ( 'ascii' ) ) #NEWLINE# f . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# pp = [ os . path . abspath ( TEMP ) ] #NEWLINE# def getenv( ) : #NEWLINE# #INDENT# env = dict ( os . environ ) #NEWLINE# env . update ( { #NEWLINE# #INDENT# 'PYTHONPATH' : ':' . join ( pp ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# return env #NEWLINE# #UNINDENT# for d in dirs : #NEWLINE# #INDENT# src = os . path . join ( BASE , d ) #NEWLINE# dst = os . path . join ( TEMP , d ) #NEWLINE# sync_2to3 ( dst = dst , src = src , patchfile = os . path . join ( TEMP , ( os . path . basename ( d ) + '.patch' ) ) , clean = options . clean ) #NEWLINE# setup_py = os . path . join ( dst , 'setup.py' ) #NEWLINE# if os . path . isfile ( setup_py ) : #NEWLINE# #INDENT# code = 'import pdb, sys, traceback\np = pdb.Pdb()\ntry:\n    import __main__\n    __main__.__dict__.update({\n        "__name__": "__main__", "__file__": "setup.py",\n        "__builtins__": __builtins__})\n    fp = open("setup.py", "rb")\n    try:\n        exec(compile(fp.read(), "setup.py", \'exec\'))\n    finally:\n        fp.close()\nexcept SystemExit:\n    raise\nexcept:\n    traceback.print_exc()\n    t = sys.exc_info()[2]\n    p.interaction(None, t)\n' #NEWLINE# ret = subprocess . call ( [ sys . executable , '-c' , code , 'build_ext' , '-i' ] , cwd = dst , env = getenv ( ) ) #NEWLINE# if ( ret != 0 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Build failed.' ) #NEWLINE# #UNINDENT# #UNINDENT# subprocess . call ( [ 'nosetests3' , '-v' , d ] , cwd = TEMP )