Ejemplo n.º 1
0
def remote_build(srcdirs=(),
                 destdir=None,
                 build_type='bdist_egg',
                 py=None,
                 remote_dir=None,
                 debug=False,
                 **kwargs):
    """Take the python distribution in the given directory, tar it up,
    ship it over to host, build it, and bring it back, placing it
    in the specified destination directory.
    """
    from fabric.api import run, put, get

    locdistbld = os.path.join(os.path.dirname(__file__), 'locdistbld.py')
    pkgs = []
    if remote_dir is None:
        remote_dir = get_tmp_user_dir()
        clean_remotedir = True
    else:
        clean_remotedir = False

    for srcdir in srcdirs:
        put_dir(srcdir, os.path.join(remote_dir, os.path.basename(srcdir)))
        pkgname = os.path.basename(srcdir)
        pkgdir = os.path.join(remote_dir, pkgname)
        remotebuilder = os.path.join(pkgdir, 'locdistbld.py')
        put(locdistbld, remotebuilder)
        remtmp = remote_tmpdir()

        result = run('%s %s -s %s -d %s -b "%s"' %
                     (py, remotebuilder, pkgdir, remtmp, build_type))

        #print result

        pkg = remote_listdir(remtmp)[
            0]  # should only have one file in directory
        pkgpath = os.path.join(destdir, pkg)

        print 'retrieving built distribution %s' % pkgpath
        get(os.path.join(remtmp, pkg), pkgpath)

        pkgs.append(pkgpath)

        if debug:
            print 'removing %s' % remtmp
        rm_remote_tree(remtmp)

    if clean_remotedir:
        if debug:
            print 'removing %s' % remote_dir
        rm_remote_tree(remote_dir)

    return 0
Ejemplo n.º 2
0
def _remote_build_and_test(fname=None,
                           pyversion='python',
                           keep=False,
                           branch=None,
                           testargs='',
                           hostname='',
                           **kwargs):
    if fname is None:
        raise RuntimeError("_remote_build_and_test: missing arg 'fname'")

    remotedir = get_tmp_user_dir()
    remote_mkdir(remotedir)

    locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')

    pushfiles = [locbldtstfile]

    build_type = 'release' if fname.endswith('.py') else 'dev'

    if os.path.isfile(fname):
        pushfiles.append(fname)
        remoteargs = ['-f', os.path.basename(fname)]
    elif os.path.isdir(fname):
        put_dir(fname, os.path.join(remotedir, os.path.basename(fname)))
        if sys.platform.startswith('win'):
            vername = 'latest'  #readlink doesn't work on windows, so try 'latest'
        else:
            vername = os.readlink(os.path.join(fname, 'downloads', 'latest'))
        remoteargs = [
            '-f',
            os.path.join(os.path.basename(fname), 'downloads', vername,
                         'go-openmdao.py')
        ]
    else:
        remoteargs = ['-f', fname]

    if branch:
        remoteargs.append('--branch=%s' % branch)

    if testargs:
        remoteargs.append('--testargs="%s"' % testargs)

    try:
        result = push_and_run(pushfiles,
                              runner=pyversion,
                              remotedir=remotedir,
                              args=remoteargs)
        return result.return_code
    finally:
        if not keep:
            print "removing remote directory: %s" % remotedir
            rm_remote_tree(remotedir)
Ejemplo n.º 3
0
def remote_build(srcdirs=(), destdir=None, build_type='bdist_egg',
                 py=None, remote_dir=None, debug=False, **kwargs):
    """Take the Python distribution in the given directory, tar it up,
    ship it over to host, build it, and bring it back, placing it
    in the specified destination directory.
    """
    from fabric.api import run, put, get

    locdistbld = os.path.join(os.path.dirname(__file__), 'locdistbld.py')
    pkgs = []
    if remote_dir is None:
        remote_dir = get_tmp_user_dir()
        clean_remotedir = True
    else:
        clean_remotedir = False

    for srcdir in srcdirs:
        put_dir(srcdir, os.path.join(remote_dir,
                                     os.path.basename(srcdir)))
        pkgname = os.path.basename(srcdir)
        pkgdir = os.path.join(remote_dir, pkgname)
        remotebuilder = os.path.join(pkgdir, 'locdistbld.py')
        put(locdistbld, remotebuilder)
        remtmp = remote_tmpdir()
        
        result = run('%s %s -s %s -d %s -b "%s"' % (py, 
                                                    remotebuilder,
                                                    pkgdir,
                                                    remtmp,
                                                    build_type))
        
        #print result
                
        pkg = remote_listdir(remtmp)[0]  # should only have one file in directory
        pkgpath = os.path.join(destdir, pkg)
        
        print 'retrieving built distribution %s' % pkgpath
        get(os.path.join(remtmp, pkg), pkgpath)
        
        pkgs.append(pkgpath)
        
        if debug:
            print 'removing %s' % remtmp
        rm_remote_tree(remtmp)
        
    if clean_remotedir:
        if debug:
            print 'removing %s' % remote_dir
        rm_remote_tree(remote_dir)
    
    return 0
Ejemplo n.º 4
0
def _remote_build_and_test(fname=None, pyversion='python', keep=False, 
                          branch=None, testargs='', hostname='', 
                          **kwargs):
    if fname is None:
        raise RuntimeError("_remote_build_and_test: missing arg 'fname'")
    
    remotedir = get_tmp_user_dir()
    remote_mkdir(remotedir)
    
    locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')
    
    pushfiles = [locbldtstfile]
    
    build_type = 'release' if fname.endswith('.py') else 'dev'
        
    if os.path.isfile(fname):
        pushfiles.append(fname)
        remoteargs = ['-f', os.path.basename(fname)]
    elif os.path.isdir(fname):
        put_dir(fname, os.path.join(remotedir, os.path.basename(fname)))
        if sys.platform.startswith('win'):
            vername = 'latest' #readlink doesn't work on windows, so try 'latest'
        else:
            vername = os.readlink(os.path.join(fname,
                                               'downloads',
                                               'latest'))
        remoteargs = ['-f', os.path.join(os.path.basename(fname),
                                         'downloads', 
                                         vername,
                                         'go-openmdao.py')]
    else:
        remoteargs = ['-f', fname]
        
    if branch:
        remoteargs.append('--branch=%s' % branch)
        
    if testargs:
        remoteargs.append('--testargs="%s"' % testargs)
        
    try:
        result = push_and_run(pushfiles, runner=pyversion,
                              remotedir=remotedir, 
                              args=remoteargs)
        return result.return_code
    finally:
        if not keep:
            print "removing remote directory: %s" % remotedir
            rm_remote_tree(remotedir)
Ejemplo n.º 5
0
def _remote_build_and_test(fname=None, pyversion='python', keep=False,
                           branch=None, testargs='', hostname='', cfg=None,
                           **kwargs):
    if fname is None:
        raise RuntimeError("_remote_build_and_test: missing arg 'fname'")

    remotedir = get_tmp_user_dir()
    remote_mkdir(remotedir)

    locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')

    pushfiles = [locbldtstfile]

    build_type = 'release' if fname.endswith('.py') else 'dev'

    if cfg and cfg.has_option(hostname, 'pull_docs')and build_type == 'dev':
        pull_docs = cfg.getboolean(hostname, 'pull_docs')
    else:
        pull_docs = False

    if os.path.isfile(fname):
        pushfiles.append(fname)
        remoteargs = ['-f', os.path.basename(fname)]
    elif os.path.isdir(fname):
        put_dir(fname, os.path.join(remotedir, os.path.basename(fname)))
        if sys.platform.startswith('win'):
            vername = 'latest'  # readlink doesn't work on windows, so try 'latest'
        else:
            vername = os.readlink(os.path.join(fname,
                                               'downloads',
                                               'latest'))
        remoteargs = ['-f', os.path.join(os.path.basename(fname),
                                         'downloads',
                                         vername,
                                         'go-openmdao-{}.py'.format(vername))]
    else:
        remoteargs = ['-f', fname]

    if branch:
        remoteargs.append('--branch=%s' % branch)

    if testargs:
        remoteargs.append('--testargs="%s"' % testargs)

    try:
        result = push_and_run(pushfiles, runner=pyversion,
                              remotedir=remotedir,
                              args=remoteargs)
        if pull_docs:
            print "pulling docs from %s" % hostname
            retrieve_docs(os.path.join('~', remotedir))
            print "doc retrieval successful"
        else:
            print "not pulling docs from %s because pull_docs is False" % hostname

        return result.return_code
    finally:
        if build_type == 'dev':
            print "pulling any pngs from %s" % hostname
            try:
                retrieve_pngs(os.path.join('~', remotedir))
                print "png retrieval successful"
            except Exception as exc:
                print "png retrieval failed:", exc

        if not keep:
            print "removing remote directory: %s" % remotedir
            rm_remote_tree(remotedir)
Ejemplo n.º 6
0
def _remote_build_and_test(fname=None,
                           pyversion='python',
                           keep=False,
                           branch=None,
                           testargs='',
                           hostname='',
                           cfg=None,
                           **kwargs):
    if fname is None:
        raise RuntimeError("_remote_build_and_test: missing arg 'fname'")

    remotedir = get_tmp_user_dir()
    remote_mkdir(remotedir)

    locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')

    pushfiles = [locbldtstfile]

    build_type = 'release' if fname.endswith('.py') else 'dev'

    if cfg and cfg.has_option(hostname, 'pull_docs') and build_type == 'dev':
        pull_docs = cfg.getboolean(hostname, 'pull_docs')
    else:
        pull_docs = False

    if os.path.isfile(fname):
        pushfiles.append(fname)
        remoteargs = ['-f', os.path.basename(fname)]
    elif os.path.isdir(fname):
        put_dir(fname, os.path.join(remotedir, os.path.basename(fname)))
        if sys.platform.startswith('win'):
            vername = 'latest'  # readlink doesn't work on windows, so try 'latest'
        else:
            vername = os.readlink(os.path.join(fname, 'downloads', 'latest'))
        remoteargs = [
            '-f',
            os.path.join(os.path.basename(fname), 'downloads', vername,
                         'go-openmdao.py')
        ]
    else:
        remoteargs = ['-f', fname]

    if branch:
        remoteargs.append('--branch=%s' % branch)

    if testargs:
        remoteargs.append('--testargs="%s"' % testargs)

    try:
        result = push_and_run(pushfiles,
                              runner=pyversion,
                              remotedir=remotedir,
                              args=remoteargs)
        if pull_docs:
            print "pulling docs from %s" % hostname
            retrieve_docs(os.path.join('~', remotedir))
            print "doc retrieval successful"
        else:
            print "not pulling docs from %s because pull_docs is False" % hostname

        return result.return_code
    finally:
        if build_type == 'dev':
            print "pulling any pngs from %s" % hostname
            try:
                retrieve_pngs(os.path.join('~', remotedir))
                print "png retrieval successful"
            except Exception as exc:
                print "png retrieval failed:", exc

        if not keep:
            print "removing remote directory: %s" % remotedir
            rm_remote_tree(remotedir)