How to use delocate - 10 common examples

To help you get started, we’ve selected a few delocate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matthew-brett / delocate / delocate / tools.py View on Github external
def _line0_says_object(line0, filename):
    line0 = line0.strip()
    for test in BAD_OBJECT_TESTS:
        if test(line0):
            return False
    if line0.startswith('Archive :'):
        # nothing to do for static libs
        return False
    if not line0.startswith(filename + ':'):
        raise InstallNameError('Unexpected first line: ' + line0)
    further_report = line0[len(filename) + 1:]
    if further_report == '':
        return True
    raise InstallNameError(
        'Too ignorant to know what "{0}" means'.format(further_report))
github matthew-brett / delocate / delocate / tools.py View on Github external
def _line0_says_object(line0, filename):
    line0 = line0.strip()
    for test in BAD_OBJECT_TESTS:
        if test(line0):
            return False
    if line0.startswith('Archive :'):
        # nothing to do for static libs
        return False
    if not line0.startswith(filename + ':'):
        raise InstallNameError('Unexpected first line: ' + line0)
    further_report = line0[len(filename) + 1:]
    if further_report == '':
        return True
    raise InstallNameError(
        'Too ignorant to know what "{0}" means'.format(further_report))
github matthew-brett / delocate / delocate / cmd / delocate_path.py View on Github external
def main():
    parser = OptionParser(
        usage="%s PATH_TO_ANALYZE\n\n" % sys.argv[0] + __doc__,
        version="%prog " + __version__)
    parser.add_options([
        Option("-L", "--lib-path",
               action="store", type='string',
               help="Output subdirectory path to copy library dependencies"),
        Option("-d", "--dylibs-only",
               action="store_true",
               help="Only analyze files with known dynamic library "
               "extensions")])
    (opts, paths) = parser.parse_args()
    if len(paths) < 1:
        parser.print_help()
        sys.exit(1)

    if opts.lib_path is None:
        opts.lib_path = '.dylibs'
    lib_filt_func = 'dylibs-only' if opts.dylibs_only else None
github matthew-brett / delocate / delocate / cmd / delocate_listdeps.py View on Github external
def main():
    parser = OptionParser(
        usage="%s WHEEL_OR_PATH_TO_ANALYZE\n\n" % sys.argv[0] + __doc__,
        version="%prog " + __version__)
    parser.add_options([
        Option("-a", "--all",
               action="store_true",
               help="Show all dependencies, including system libs"),
        Option("-d", "--depending",
               action="store_true",
               help="Show libraries depending on dependencies")])
    (opts, paths) = parser.parse_args()
    if len(paths) < 1:
        parser.print_help()
        sys.exit(1)

    multi = len(paths) > 1
    for path in paths:
        if multi:
            print(path + ':')
github matthew-brett / delocate / delocate / cmd / delocate_fuse.py View on Github external
def main():
    parser = OptionParser(
        usage="%s WHEEL1 WHEEL2\n\n" % sys.argv[0] + __doc__,
        version="%prog " + __version__)
    parser.add_option(
        Option("-w", "--wheel-dir",
               action="store", type='string',
               help="Directory to store delocated wheels (default is to "
               "overwrite WHEEL1 input)"))
    parser.add_option(
        Option("-v", "--verbose",
               action="store_true",
               help="Show libraries copied during fix"))
    (opts, wheels) = parser.parse_args()
    if len(wheels) != 2:
        parser.print_help()
        sys.exit(1)
    wheel1, wheel2 = [abspath(expanduser(wheel)) for wheel in wheels]
    if opts.wheel_dir is None:
        out_wheel = wheel1
github matthew-brett / delocate / delocate / cmd / delocate_patch.py View on Github external
def main():
    parser = OptionParser(
        usage="%s WHEEL_FILENAME PATCH_FNAME\n\n" % sys.argv[0] + __doc__,
        version="%prog " + __version__)
    parser.add_option(
        Option("-w", "--wheel-dir",
               action="store", type='string',
               help="Directory to store patched wheel (default is to "
               "overwrite input)"))
    parser.add_option(
        Option("-v", "--verbose",
               action="store_true",
               help="Print input and output wheels"))
    (opts, args) = parser.parse_args()
    if len(args) != 2:
        parser.print_help()
        sys.exit(1)
    wheel, patch_fname = args
    if opts.wheel_dir:
        wheel_dir = expanduser(opts.wheel_dir)
github matthew-brett / delocate / delocate / wheeltools.py View on Github external
out_path = dirname(in_wheel) if out_path is None else abspath(out_path)
    wf = WheelFile(in_wheel)
    info_fname = _get_wheelinfo_name(wf)
    # Check what tags we have
    in_fname_tags = wf.parsed_filename.groupdict()['plat'].split('.')
    extra_fname_tags = [tag for tag in platforms if tag not in in_fname_tags]
    in_wheel_base, ext = splitext(basename(in_wheel))
    out_wheel_base = '.'.join([in_wheel_base] + list(extra_fname_tags))
    out_wheel = pjoin(out_path, out_wheel_base + ext)
    if exists(out_wheel) and not clobber:
        raise WheelToolsError('Not overwriting {0}; set clobber=True '
                              'to overwrite'.format(out_wheel))
    with InWheelCtx(in_wheel) as ctx:
        info = read_pkg_info(info_fname)
        if info['Root-Is-Purelib'] == 'true':
            raise WheelToolsError('Cannot add platforms to pure wheel')
        in_info_tags = [tag for name, tag in info.items() if name == 'Tag']
        # Python version, C-API version combinations
        pyc_apis = ['-'.join(tag.split('-')[:2]) for tag in in_info_tags]
        # unique Python version, C-API version combinations
        pyc_apis = unique_by_index(pyc_apis)
        # Add new platform tags for each Python version, C-API combination
        required_tags = ['-'.join(tup) for tup in product(pyc_apis, platforms)]
        needs_write = False
        for req_tag in required_tags:
            if req_tag in in_info_tags:
                continue
            needs_write = True
            info.add_header('Tag', req_tag)
        if needs_write:
            write_pkg_info(info_fname, info)
            # Tell context manager to write wheel on exit by setting filename
github matthew-brett / delocate / delocate / wheeltools.py View on Github external
-------
    out_wheel : None or str
        Absolute path of wheel file written, or None if no wheel file written.
    """
    in_wheel = abspath(in_wheel)
    out_path = dirname(in_wheel) if out_path is None else abspath(out_path)
    wf = WheelFile(in_wheel)
    info_fname = _get_wheelinfo_name(wf)
    # Check what tags we have
    in_fname_tags = wf.parsed_filename.groupdict()['plat'].split('.')
    extra_fname_tags = [tag for tag in platforms if tag not in in_fname_tags]
    in_wheel_base, ext = splitext(basename(in_wheel))
    out_wheel_base = '.'.join([in_wheel_base] + list(extra_fname_tags))
    out_wheel = pjoin(out_path, out_wheel_base + ext)
    if exists(out_wheel) and not clobber:
        raise WheelToolsError('Not overwriting {0}; set clobber=True '
                              'to overwrite'.format(out_wheel))
    with InWheelCtx(in_wheel) as ctx:
        info = read_pkg_info(info_fname)
        if info['Root-Is-Purelib'] == 'true':
            raise WheelToolsError('Cannot add platforms to pure wheel')
        in_info_tags = [tag for name, tag in info.items() if name == 'Tag']
        # Python version, C-API version combinations
        pyc_apis = ['-'.join(tag.split('-')[:2]) for tag in in_info_tags]
        # unique Python version, C-API version combinations
        pyc_apis = unique_by_index(pyc_apis)
        # Add new platform tags for each Python version, C-API combination
        required_tags = ['-'.join(tup) for tup in product(pyc_apis, platforms)]
        needs_write = False
        for req_tag in required_tags:
            if req_tag in in_info_tags:
                continue
github matthew-brett / delocate / delocate / cmd / delocate_listdeps.py View on Github external
help="Show libraries depending on dependencies")])
    (opts, paths) = parser.parse_args()
    if len(paths) < 1:
        parser.print_help()
        sys.exit(1)

    multi = len(paths) > 1
    for path in paths:
        if multi:
            print(path + ':')
            indent = '   '
        else:
            indent = ''
        if isdir(path):
            lib_dict = tree_libs(path)
            lib_dict = stripped_lib_dict(lib_dict, realpath(getcwd()) + psep)
        else:
            lib_dict = wheel_libs(path)
        keys = sorted(lib_dict)
        if not opts.all:
            keys = [key for key in keys if filter_system_libs(key)]
        if not opts.depending:
            if len(keys):
                print(indent + ('\n' + indent).join(keys))
            continue
        i2 = indent + '    '
        for key in keys:
            print(indent + key + ':')
            libs = lib_dict[key]
            if len(libs):
                print(i2 + ('\n' + i2).join(libs))
github matthew-brett / delocate / delocate / cmd / delocate_path.py View on Github external
"extensions")])
    (opts, paths) = parser.parse_args()
    if len(paths) < 1:
        parser.print_help()
        sys.exit(1)

    if opts.lib_path is None:
        opts.lib_path = '.dylibs'
    lib_filt_func = 'dylibs-only' if opts.dylibs_only else None
    multi = len(paths) > 1
    for path in paths:
        if multi:
            print(path)
        # evaluate paths relative to the path we are working on
        lib_path = os.path.join(path, opts.lib_path)
        delocate_path(path, lib_path, lib_filt_func)