예제 #1
0
파일: _build.py 프로젝트: code-happy/mypy
def submit_build(args):

    binstar = get_binstar(args)

    path = abspath(args.path)
    log.info('Getting build product: %s' % abspath(args.path))

    build_matrix = load_all_binstar_yml(path)
    builds = list(serialize_builds(build_matrix))
    log.info('Submitting %i sub builds' % len(builds))
    for i, build in enumerate(builds):
        log.info(' %i)' % i +
                 ' %(platform)-10s  %(engine)-15s  %(env)-15s' % build)

    if not args.dry_run:
        with mktemp() as tmp:
            with tarfile.open(tmp, mode='w|bz2') as tf:
                tf.add(path, '.')

            with open(tmp, mode='rb') as fd:

                build_no = binstar.submit_for_build(args.package.user,
                                                    args.package.name, fd,
                                                    builds)
        log.info('Build %s submitted' % build_no)
    else:
        log.info('Build not submitted (dry-run)')
def main(args):

    binstar = get_binstar(args, cls=BinstarBuildAPI)

    package_name = None
    user_name = None

    if args.git_url:
        args.path = args.git_url

    if args.git_url or is_url(args.path):
        args.git_url = args.path
        args.git_url_path = get_urlpath(args.path)
        args.dont_git_ignore = True

        submit_git_build(binstar, args)


    # not a github repo (must check for valid .binstar.yml file
    else:
        binstar_yml = join(args.path, '.binstar.yml')

        if not isfile(binstar_yml):
            raise UserError("file %s does not exist\n perhaps you should run\n\n    anaconda build init\n" % binstar_yml)

        package_name = None
        user_name = None
        build_matrix = load_all_binstar_yml(args.path)
        for build in build_matrix:
            if build.get('package'):
                package_name = build.get('package')
            if build.get('user'):
                user_name = build.get('user')

        # Force package to exist
        if args.package:
            if user_name and not args.package.user == user_name:
                log.warn('User name does not match the user specified in the .binstar.yml file (%s != %s)', args.package.user, user_name)
            user_name = args.package.user
            if package_name and not args.package.name == package_name:
                log.warn('Package name does not match the user specified in the .binstar.yml file (%s != %s)', args.package.name, package_name)
            package_name = args.package.name
        else:
            if user_name is None:
                user = binstar.user()
                user_name = user['login']
            if not package_name:
                raise UserError("You must specify the package name in the .binstar.yml file or the command line")

        try:
            _ = binstar.package(user_name, package_name)
        except errors.NotFound:
            log.error("The package %s/%s does not exist." % (user_name, package_name))
            log.error("Run: \n\n    binstar package --create %s/%s\n\n to create this package" % (user_name, package_name))
            raise errors.NotFound('Package %s/%s' % (user_name, package_name))
        args.package = PackageSpec(user_name, package_name)

        submit_build(binstar, args)
예제 #3
0
def submit_build(binstar, args):

    path = abspath(args.path)

    log.info('Getting build product: %s' % abspath(args.path))

    build_matrix = load_all_binstar_yml(path)
    builds = list(serialize_builds(build_matrix))

    if args.platform:

        log.info("Only selecting builds on platform %s" % args.platform)
        builds = [b for b in builds if b['platform'] == args.platform]

    if not builds:
        msg = "No build instructions found"
        if args.platform:
            msg += " for platform %s" % args.platform
        raise errors.BinstarError(msg)

    log.info('Submitting %i sub builds' % len(builds))
    for i, build in enumerate(builds):
        log.info(' %i)' % i + ' %(platform)-10s  %(engine)-15s  %(env)-15s' % build)

    if not args.dry_run:
        if args.git_url:
            log.info("Submitting the following repo for package creation: %s" % args.git_url)

        else:
            with mktemp() as tmp:
                log.info("Archiving build directory for upload ...")
                with tarfile.open(tmp, mode='w|bz2') as tf:
                    exclude = ExcludeGit(path, use_git_ignore=not args.dont_git_ignore)
                    tf.add(path, '.', exclude=exclude)

                log.info("Created archive (%i files); Uploading to Anaconda Build service" % exclude.num_included)
                queue_tags = []
                if args.buildhost:
                    queue_tags.append('hostname:%s' % args.buildhost)

                if args.dist:
                    queue_tags.append('dist:%s' % args.dist)

                with open(tmp, mode='rb') as fd:

                    # TODO: change channels= to labels=
                    build = binstar.submit_for_build(args.package.user, args.package.name, fd, builds,
                                                     channels=args.labels,
                                                     queue=args.queue, queue_tags=queue_tags,
                                                     test_only=args.test_only, callback=upload_print_callback(args))

                if args.tail:
                    tail_sub_build(binstar, args, build['build_no'])
                else:
                    print_build_results(args, build, binstar)
    else:
        log.info('Build not submitted (dry-run)')
def main(args):

    binstar = get_binstar()

    # Force user auth
    user = binstar.user()

    package_name = None
    user_name = None

    binstar_yml = join(args.path, '.binstar.yml')

    if not isfile(binstar_yml):
        raise UserError("file %s does not exist" % binstar_yml)

    build_matrix = load_all_binstar_yml(args.path)
    for build in build_matrix:
        package_name = build.get('package')
        user_name = build.get('user')

    # Force package to exist
    if args.package:
        if user_name and not args.package.user == user_name:
            log.warn('User name does not match the user specified in the .binstar.yml file (%s != %s)', args.package.user, user_name)
        user_name = args.package.user
        if package_name and not args.package.name == package_name:
            log.warn('Package name does not match the user specified in the .binstar.yml file (%s != %s)', args.package.name, package_name)
        package_name = args.package.name
    else:
        if user_name is None:
            user_name = user['login']
        if not package_name:
            raise UserError("You must specify the package name in the .binstar.yml file or the command line")

    try:
        _ = binstar.package(user_name, package_name)
    except errors.NotFound:
        log.error("The package %s/%s does not exist." % (user_name, package_name))
        log.error("Run: 'binstar package --create %s/%s' to create this package" % (user_name, package_name))
        raise errors.NotFound('Package %s/%s' % (user_name, package_name))
    args.package = PackageSpec(user_name, package_name)

    if args.resubmit:
        log.info("Re submit build %s", args.resubmit)
        return resubmit_build(binstar, args)

    if args.tail:
        return tail(binstar, args)

    if args.halt:
        return halt_build(binstar, args)

    if args.list:
        return list_builds(binstar, args)
def submit_build(args):

    binstar = get_binstar(args)

    path = abspath(args.path)
    log.info('Getting build product: %s' % abspath(args.path))

    build_matrix = load_all_binstar_yml(path)
    builds = list(serialize_builds(build_matrix))
    log.info('Submitting %i sub builds' % len(builds))
    for i, build in enumerate(builds):
        log.info(' %i)' % i + ' %(platform)-10s  %(engine)-15s  %(env)-15s' % build)

    if not args.dry_run:
        with mktemp() as tmp:
            with tarfile.open(tmp, mode='w|bz2') as tf:
                tf.add(path, '.')

            with open(tmp, mode='rb') as fd:

                build_no = binstar.submit_for_build(args.package.user, args.package.name, fd, builds)
        log.info('Build %s submitted' % build_no)
    else:
        log.info('Build not submitted (dry-run)')
예제 #6
0
def submit_build(binstar, args):

    path = abspath(args.path)

    log.info('Getting build product: %s' % abspath(args.path))

    build_matrix = load_all_binstar_yml(path)
    builds = list(serialize_builds(build_matrix))

    if args.platform:

        log.info("Only selecting builds on platform %s" % args.platform)
        builds = [b for b in builds if b['platform'] == args.platform]

    if not builds:
        msg = "No build instructions found"
        if args.platform:
            msg += " for platform %s" % args.platform
        raise errors.BinstarError(msg)

    log.info('Submitting %i sub builds' % len(builds))
    for i, build in enumerate(builds):
        log.info(' %i)' % i +
                 ' %(platform)-10s  %(engine)-15s  %(env)-15s' % build)

    if not args.dry_run:
        if args.git_url:
            log.info("Submitting the following repo for package creation: %s" %
                     args.git_url)

        else:
            with mktemp() as tmp:
                log.info("Archiving build directory for upload ...")
                with tarfile.open(tmp, mode='w|bz2') as tf:
                    exclude = ExcludeGit(
                        path, use_git_ignore=not args.dont_git_ignore)
                    tf.add(path, '.', exclude=exclude)

                log.info(
                    "Created archive (%i files); Uploading to Anaconda Build service"
                    % exclude.num_included)
                queue_tags = []
                if args.buildhost:
                    queue_tags.append('hostname:%s' % args.buildhost)

                if args.dist:
                    queue_tags.append('dist:%s' % args.dist)

                with open(tmp, mode='rb') as fd:

                    # TODO: change channels= to labels=
                    build = binstar.submit_for_build(
                        args.package.user,
                        args.package.name,
                        fd,
                        builds,
                        channels=args.labels,
                        queue=args.queue,
                        queue_tags=queue_tags,
                        test_only=args.test_only,
                        callback=upload_print_callback(args))

                print_build_results(args, build, binstar)

    else:
        log.info('Build not submitted (dry-run)')
예제 #7
0
def main(args):

    binstar = get_binstar(args, cls=BinstarBuildAPI)

    package_name = None
    user_name = None

    if args.git_url:
        args.path = args.git_url

    if args.git_url or is_url(args.path):
        args.git_url = args.path
        args.git_url_path = get_urlpath(args.path)
        args.dont_git_ignore = True

        submit_git_build(binstar, args)

    # not a github repo (must check for valid .binstar.yml file
    else:
        binstar_yml = join(args.path, '.binstar.yml')

        if not isfile(binstar_yml):
            raise UserError(
                "file %s does not exist\n perhaps you should run\n\n    anaconda build init\n"
                % binstar_yml)

        package_name = None
        user_name = None
        build_matrix = load_all_binstar_yml(args.path)
        for build in build_matrix:
            if build.get('package'):
                package_name = build.get('package')
            if build.get('user'):
                user_name = build.get('user')

        # Force package to exist
        if args.package:
            if user_name and not args.package.user == user_name:
                log.warn(
                    'User name does not match the user specified in the .binstar.yml file (%s != %s)',
                    args.package.user, user_name)
            user_name = args.package.user
            if package_name and not args.package.name == package_name:
                log.warn(
                    'Package name does not match the user specified in the .binstar.yml file (%s != %s)',
                    args.package.name, package_name)
            package_name = args.package.name
        else:
            if user_name is None:
                user = binstar.user()
                user_name = user['login']
            if not package_name:
                raise UserError(
                    "You must specify the package name in the .binstar.yml file or the command line"
                )

        try:
            _ = binstar.package(user_name, package_name)
        except errors.NotFound:
            log.error("The package %s/%s does not exist." %
                      (user_name, package_name))
            log.error(
                "Run: \n\n    anaconda package --create %s/%s\n\n to create this package"
                % (user_name, package_name))
            raise errors.NotFound('Package %s/%s' % (user_name, package_name))
        args.package = PackageSpec(user_name, package_name)

        submit_build(binstar, args)
예제 #8
0
파일: _build.py 프로젝트: code-happy/mypy
def main(args):

    binstar = get_binstar()

    # Force user auth
    user = binstar.user()

    package_name = None
    user_name = None

    binstar_yml = join(args.path, '.binstar.yml')

    if not isfile(binstar_yml):
        raise UserError("file %s does not exist" % binstar_yml)

    build_matrix = load_all_binstar_yml(args.path)
    for build in build_matrix:
        package_name = build.get('package')
        user_name = build.get('user')

    # Force package to exist
    if args.package:
        if user_name and not args.package.user == user_name:
            log.warn(
                'User name does not match the user specified in the .binstar.yml file (%s != %s)',
                args.package.user, user_name)
        user_name = args.package.user
        if package_name and not args.package.name == package_name:
            log.warn(
                'Package name does not match the user specified in the .binstar.yml file (%s != %s)',
                args.package.name, package_name)
        package_name = args.package.name
    else:
        if user_name is None:
            user_name = user['login']
        if not package_name:
            raise UserError(
                "You must specify the package name in the .binstar.yml file or the command line"
            )

    try:
        _ = binstar.package(user_name, package_name)
    except errors.NotFound:
        log.error("The package %s/%s does not exist." %
                  (user_name, package_name))
        log.error(
            "Run: 'binstar package --create %s/%s' to create this package" %
            (user_name, package_name))
        raise errors.NotFound('Package %s/%s' % (user_name, package_name))
    args.package = PackageSpec(user_name, package_name)

    if args.resubmit:
        log.info("Re submit build %s", args.resubmit)
        return resubmit_build(binstar, args)

    if args.tail:
        return tail(binstar, args)

    if args.halt:
        return halt_build(binstar, args)

    if args.list:
        return list_builds(binstar, args)