How to use the entrypoints.reader.EntryPointsScanner function in entrypoints

To help you get started, we’ve selected a few entrypoints 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 takluyver / entrypoints / entrypoints / diagnose.py View on Github external
def check_shadowing():
    scanner = EntryPointsScanner()
    distros_by_name = defaultdict(list)
    any_shadowed = False

    for path in sys.path:
        locn_ep = scanner.entrypoints_for_path(path)
        for distro in locn_ep['distributions']:
            distros_by_name[distro['name']].append((path, distro))

    for distro_name, found in sorted(distros_by_name.items(), key=str):
        if len(found) > 1:
            any_shadowed = True
            print("Multiple installations of {!r}:".format(distro_name))
            visible_path, visible_distro = found[0]
            print(" * {} in {}".format(visible_distro['version'], visible_path))
            for path, distro in found[1:]:
                print("   {} in {}".format(distro['version'], path))
github takluyver / entrypoints / entrypoints / diagnose.py View on Github external
def check_cache_validity():
    with_cache = EntryPointsScanner()
    if not with_cache.user_cache:
        print("No cached data to check.")
        return

    without_cache = EntryPointsScanner(cache_file='')
    cache_valid = True
    needs_manual_refresh = False

    for path, cache_data in with_cache.user_cache.items():
        scan_data = without_cache.entrypoints_for_path(path)
        if scan_data['distributions'] == cache_data['distributions']:
            continue   # Cache is correct

        cache_valid = False
        if path.endswith('.egg') or (cache_data['mtime'] == scan_data['mtime']):
            needs_manual_refresh = True
            print("Cache for {} is invalid".format(path))
        else:
            print("Cache for {} is outdated".format(path))

    if needs_manual_refresh:
github takluyver / entrypoints / entrypoints / diagnose.py View on Github external
def check_cache_validity():
    with_cache = EntryPointsScanner()
    if not with_cache.user_cache:
        print("No cached data to check.")
        return

    without_cache = EntryPointsScanner(cache_file='')
    cache_valid = True
    needs_manual_refresh = False

    for path, cache_data in with_cache.user_cache.items():
        scan_data = without_cache.entrypoints_for_path(path)
        if scan_data['distributions'] == cache_data['distributions']:
            continue   # Cache is correct

        cache_valid = False
        if path.endswith('.egg') or (cache_data['mtime'] == scan_data['mtime']):
            needs_manual_refresh = True