Example #1
0
def get_chrpath():
    assert sys.platform.startswith('linux')
    global chrpath
    if not chrpath:
        chrpath = external.find_executable('chrpath')
        assert isfile(chrpath)
    return chrpath
Example #2
0
def handle_binstar_upload(path, args):
    import subprocess
    from conda.builder.external import find_executable

    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
""" % path)
        return

    binstar = find_executable('binstar')
    if binstar is None:
        sys.exit('''
Error: cannot locate binstar (required for upload)
# Try:
# $ conda install binstar
''')
    print("Uploading to binstar")
    args = [binstar, 'upload', path]
    if config.binstar_personal:
        args += ['--personal']
    subprocess.call(args)
Example #3
0
def install_with_pip(prefix, index, specs):
    r = Resolve(index)
    for_conda = []


    pip_path = external.find_executable('pip')
    if not pip_path:
        print("Pip not found, running `conda install pip` ...")
        try:
            install_package(prefix, 'pip')
        except Exception as e:
            print("Could not install pip --- continuing...")
            return specs

    for s in specs:
        try:
            next(r.find_matches(MatchSpec(s)))
        except StopIteration:
            if s == 'pip':
                for_conda.append(s)
                continue
            print("Conda package not available for %s, attempting to install "
                  "via pip" % s)
            pip_install(prefix, s)
        else:
            for_conda.append(s)
    return for_conda
Example #4
0
File: post.py Project: hajs/conda
def _get_rpath(f):
    objdump = external.find_executable("objdump")
    output = check_output([objdump, "-x", f])
    for line in output.splitlines():
        columns = line.split()
        if columns and columns[0] == "RPATH":
            return columns[1]
    return ""
Example #5
0
def mk_relative(f):
    assert sys.platform != "win32"
    if f.startswith("bin/"):
        fix_shebang(f)

    path = join(build_prefix, f)
    if sys.platform.startswith("linux") and is_obj(path):
        rpath = "$ORIGIN/" + utils.rel_lib(f)
        chrpath = external.find_executable("chrpath")
        call([chrpath, "-r", rpath, path])

    if sys.platform == "darwin" and is_obj(path):
        mk_relative_osx(path)
Example #6
0
def check_external():
    import os
    import conda.builder.external as external

    if sys.platform.startswith('linux'):
        chrpath = external.find_executable('chrpath')
        if chrpath is None:
            sys.exit("""\
Error:
    Did not find 'chrpath' in: %s
    'chrpath' is necessary for building conda packages on Linux with
    relocatable ELF libraries.  You can install chrpath using apt-get,
    yum or conda.
""" % (os.pathsep.join(external.dir_paths)))
Example #7
0
def apply_patch(src_dir, path):
    print('Applying patch: %r' % path)
    if not isfile(path):
        sys.exit('Error: no such patch: %s' % path)

    patch = external.find_executable('patch')
    if patch is None:
        sys.exit("""\
Error:
    Did not find 'patch' in: %s
    You can install 'patch' using apt-get, yum (Linux), Xcode (MacOSX),
    or conda, cygwin (Windows),
""" % (os.pathsep.join(external.dir_paths)))
    check_call([patch, '-p0', '-i', path], cwd=src_dir)
Example #8
0
def check_external():
    import os
    import conda.builder.external as external

    if sys.platform.startswith('linux'):
        chrpath = external.find_executable('chrpath')
        if chrpath is None:
            sys.exit("""\
Error:
    Did not find 'chrpath' in: %s
    'chrpath' is necessary for building conda packages on Linux with
    relocatable ELF libraries.  You can install chrpath using apt-get,
    yum or conda.
""" % (os.pathsep.join(external.dir_paths)))
Example #9
0
File: post.py Project: hajs/conda
def mk_relative(f):
    assert sys.platform != 'win32'
    if f.startswith('bin/'):
        fix_shebang(f)

    path = join(build_prefix, f)
    if sys.platform.startswith('linux') and is_obj(path):
        rpath = '$ORIGIN/' + utils.rel_lib(f)
        current_rpath = _get_rpath(path)
        if "$ORIGIN" in current_rpath:
            print("skipping relative rpath", current_rpath)
            return
        chrpath = external.find_executable('chrpath')
        call([chrpath, '-r', rpath, path])

    if sys.platform == 'darwin' and is_obj(path):
        mk_relative_osx(path)
Example #10
0
File: post.py Project: dmj111/conda
def mk_relative(f):
    assert sys.platform != 'win32'
    if f.startswith('bin/'):
        fix_shebang(f)

    path = join(build_prefix, f)
    if sys.platform == 'linux2' and is_obj(path):
        runpath = '$ORIGIN/' + utils.rel_lib(f)
        chrpath = external.find_executable('chrpath')
        if chrpath is None:
            sys.exit("""\
Error:
    Did not find 'chrpath' in: %s
    'chrpath' is necessary for building conda packages on Linux with
    relocatable ELF libraries.  You can install chrpath using apt-get,
    yum or conda.
""" % (os.pathsep.join(external.dir_paths)))
        call([chrpath, '-c', '-r', runpath, path])

    if sys.platform == 'darwin' and is_obj(path):
        mk_relative_osx(path)
Example #11
0
def handle_binstar_upload(path, args):
    import subprocess
    from conda.builder.external import find_executable

    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
""" % path)
        return

    binstar = find_executable('binstar')
    if binstar is None:
        sys.exit('''
Error: cannot locate binstar (required for upload)
# Try:
# $ conda install binstar
''')
    print("Uploading to binstar")
    args = [binstar, 'upload', path]

    if config.binstar_user:
        args += ['--user', config.binstar_user]

    if config.binstar_personal:
        args += ['--personal']
    subprocess.call(args)
Example #12
0
def mk_relative(f):
    assert sys.platform != "win32"
    if f.startswith("bin/"):
        fix_shebang(f)

    path = join(build_prefix, f)
    if sys.platform == "linux2" and is_obj(path):
        rpath = "$ORIGIN/" + utils.rel_lib(f)
        chrpath = external.find_executable("chrpath")
        if chrpath is None:
            sys.exit(
                """\
Error:
    Did not find 'chrpath' in: %s
    'chrpath' is necessary for building conda packages on Linux with
    relocatable ELF libraries.  You can install chrpath using apt-get,
    yum or conda.
"""
                % (os.pathsep.join(external.dir_paths))
            )
        call([chrpath, "-r", rpath, path])

    if sys.platform == "darwin" and is_obj(path):
        mk_relative_osx(path)
Example #13
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)])