Exemplo n.º 1
0
def execute(args, parser):
    import sys
    import shutil
    import tarfile
    import tempfile
    from os.path import abspath, isdir, isfile

    import conda.builder.build as build
    from conda.builder.config import croot
    import conda.builder.source as source
    from conda.builder.metadata import MetaData
    from conda.lock import Locked

    with Locked(croot):
        for arg in args.recipe:
            if isfile(arg):
                recipe_dir = tempfile.mkdtemp()
                t = tarfile.open(arg, 'r:*')
                t.extractall(path=recipe_dir)
                t.close()
                need_cleanup = True
            else:
                recipe_dir = abspath(arg)
                need_cleanup = False

            if not isdir(recipe_dir):
                sys.exit("Error: no such directory: %s" % recipe_dir)

            m = MetaData(recipe_dir)
            if args.test:
                build.test(m)
            elif args.source:
                source.provide(m.path, m.get_section('source'))
                print('Source tree in:', source.get_dir())
            else:
                build.build(m)

            if need_cleanup:
                shutil.rmtree(recipe_dir)

            print("""\
# If you want to upload this package to binstar.org, type:
#
# $ binstar upload %s
""" % build.bldpkg_path(m) )
Exemplo n.º 2
0
def execute(args, parser):
    import sys
    from os.path import abspath, isdir

    import conda.builder.build as build
    import conda.builder.source as source
    from conda.builder.metadata import MetaData

    for arg in args.recipe:
        recipe_dir = abspath(arg)
        if not isdir(recipe_dir):
            sys.exit("Error: no such directory: %s" % recipe_dir)

        m = MetaData(recipe_dir)
        if args.test:
            build.test(m)
        elif args.source:
            source.provide(m.path, m.get_section('source'))
            print 'Source tree in:', source.get_dir()
        else:
            build.build(m)
Exemplo n.º 3
0
def execute(args, parser):
    import sys
    import shutil
    import tarfile
    import tempfile
    from os.path import abspath, isdir, isfile, join

    from conda.lock import Locked
    import conda.builder.build as build
    import conda.builder.source as source
    from conda.builder.config import croot
    from conda.builder.metadata import MetaData

    with Locked(croot):
        for arg in args.recipe:
            if isfile(arg):
                if arg.endswith(('.tar', '.tar.gz', '.tgz', '.tar.bz2')):
                    recipe_dir = tempfile.mkdtemp()
                    t = tarfile.open(arg, 'r:*')
                    t.extractall(path=recipe_dir)
                    t.close()
                    need_cleanup = True
                else:
                    print("Ignoring: %s" % arg)
                    continue
            else:
                recipe_dir = abspath(arg)
                need_cleanup = False

            if not isdir(recipe_dir):
                # See if it's a spec and the directory is in conda-recipes
                recipe_dir = join(config.root_dir, 'conda-recipes', arg)
                if not isdir(recipe_dir):
                    # if --use-pypi and recipe_dir is a spec
                    # try to create the skeleton
                    if args.pypi:
                        from conda.from_pypi import create_recipe
                        try:
                            recipe_dir = create_recipe(arg)
                        except:
                            recipe_dir = abspath(arg)
                    if not isdir(recipe_dir):
                        sys.exit("Error: no such directory: %s" % recipe_dir)

            m = MetaData(recipe_dir)
            if args.check and len(args.recipe) > 1:
                print(m.path)
            m.check_fields()
            if args.check:
                continue
            if args.output:
                print(build.bldpkg_path(m))
                continue
            elif args.test:
                build.test(m, pypi=args.pypi)
            elif args.source:
                source.provide(m.path, m.get_section('source'))
                print('Source tree in:', source.get_dir())
            else:
                build.build(m, pypi=args.pypi)
                if not args.notest:
                    build.test(m, pypi=args.pypi)

            if need_cleanup:
                shutil.rmtree(recipe_dir)

            handle_binstar_upload(build.bldpkg_path(m), args)
Exemplo n.º 4
0
def execute(args, parser):
    import sys
    import shutil
    import tarfile
    import tempfile
    from os.path import abspath, isdir, isfile

    import conda.builder.build as build
    from conda.builder.external import find_executable
    from conda.builder.config import croot
    import conda.builder.source as source
    from conda.builder.metadata import MetaData
    from conda.lock import Locked

    with Locked(croot):
        for arg in args.recipe:
            if isfile(arg):
                if arg.endswith(('.tar', '.tar.gz', '.tgz', '.tar.bz2')):
                    recipe_dir = tempfile.mkdtemp()
                    t = tarfile.open(arg, 'r:*')
                    t.extractall(path=recipe_dir)
                    t.close()
                    need_cleanup = True
                else:
                    print("Ignoring: %s" % arg)
                    continue
            else:
                recipe_dir = abspath(arg)
                need_cleanup = False

            if not isdir(recipe_dir):
                sys.exit("Error: no such directory: %s" % recipe_dir)

            m = MetaData(recipe_dir)
            if args.check and len(args.recipe) > 1:
                print(m.path)
            m.check_fields()
            if args.check:
                continue
            if args.output:
                print(build.bldpkg_path(m))
                continue
            elif args.test:
                build.test(m)
            elif args.source:
                source.provide(m.path, m.get_section('source'))
                print('Source tree in:', source.get_dir())
            else:
                build.build(m)

            if need_cleanup:
                shutil.rmtree(recipe_dir)

            if args.binstar_upload is None:
                args.yes = False
                args.dry_run = False
                upload = common.confirm_yn(
                    args,
                    message="Do you want to upload this "
                    "package to binstar", default='yes', exit_no=False)
            else:
                upload = args.binstar_upload

            if not upload:
                print("""\
# If you want to upload this package to binstar.org later, type:
#
# $ binstar upload %s
""" % build.bldpkg_path(m))
                continue

            binstar = find_executable('binstar')
            if binstar is None:
                sys.exit('''
Error: cannot locate binstar (required for upload)
# Try:
# $ conda install binstar
''')
            subprocess.call([binstar, 'upload', build.bldpkg_path(m)])
Exemplo n.º 5
0
def execute(args, parser):
    import sys
    import shutil
    import tarfile
    import tempfile
    from os.path import abspath, isdir, isfile, join

    from conda.lock import Locked
    import conda.builder.build as build
    import conda.builder.source as source
    from conda.builder.config import croot
    from conda.builder.metadata import MetaData

    check_external()

    with Locked(croot):
        for arg in args.recipe:
            if isfile(arg):
                if arg.endswith(('.tar', '.tar.gz', '.tgz', '.tar.bz2')):
                    recipe_dir = tempfile.mkdtemp()
                    t = tarfile.open(arg, 'r:*')
                    t.extractall(path=recipe_dir)
                    t.close()
                    need_cleanup = True
                else:
                    print("Ignoring non-recipe: %s" % arg)
                    continue
            else:
                recipe_dir = abspath(arg)
                need_cleanup = False

            if not isdir(recipe_dir):
                # See if it's a spec and the directory is in conda-recipes
                recipe_dir = join(config.root_dir, 'conda-recipes', arg)
                if not isdir(recipe_dir):
                    # if --use-pypi and recipe_dir is a spec
                    # try to create the skeleton
                    if args.pypi:
                        from conda.from_pypi import create_recipe
                        try:
                            recipe_dir = create_recipe(arg)
                        except:
                            recipe_dir = abspath(arg)
                    if not isdir(recipe_dir):
                        sys.exit("Error: no such directory: %s" % recipe_dir)

            m = MetaData(recipe_dir)
            binstar_upload = False
            if args.check and len(args.recipe) > 1:
                print(m.path)
            m.check_fields()
            if args.check:
                continue
            if args.output:
                print(build.bldpkg_path(m))
                continue
            elif args.test:
                build.test(m, pypi=args.pypi)
            elif args.source:
                source.provide(m.path, m.get_section('source'))
                print('Source tree in:', source.get_dir())
            else:
                build.build(m, pypi=args.pypi)
                if not args.notest:
                    build.test(m, pypi=args.pypi)
                binstar_upload = True

            if need_cleanup:
                shutil.rmtree(recipe_dir)

            if binstar_upload:
                handle_binstar_upload(build.bldpkg_path(m), args)