示例#1
0
def getDependencyInfosForDeferred():
    """
    Return dictionary with lists of configuration files
    for the dependencies of the deferred eggs.
    """
    deferred = ['zc.table', 'hurry.workflow']
    # XXX: Assuming that all dependencies should be autoincluded
    # will probably get us into trouble, but let's see how big trouble.
    # *zc.table* is an example of a dependency, whose *configure.zcml*
    # will not run in Plone environment.
    # Some better solution than just a blacklist would be welcome.
    from sauna.reload import reload_paths
    zcml_to_look_for = ('meta.zcml', 'configure.zcml', 'overrides.zcml')
    deps = ZCMLInfo(zcml_to_look_for)
    for ep in iter_entry_points('z3c.autoinclude.plugin'):
        if ep.module_name == DEFERRED_TARGET:
            deferred.append(ep.dist.project_name)
            # XXX: We cannot call DependencyFinder(ep.dist).includableInfo,
            # because it eventually imports also our development packages
            # while resolving existence of *zcml_to_look_for*.
            finder = DependencyFinder(ep.dist)
            info = ZCMLInfo(zcml_to_look_for)
            for req in finder.context.requires():
                # Skip missing and deferred requirements
                dist = ws.find(req)  # find req from the current working set
                if dist is None or dist.location in reload_paths:
                    continue
                # Resolve ZCMLs to be loaded for the other requirements
                dist_manager = DistributionManager(get_provider(req))
                for dotted_name in dist_manager.dottedNames():
                    module = resolve(dotted_name)
                    for candidate in zcml_to_look_for:
                        candidate_path = os.path.join(
                            os.path.dirname(module.__file__), candidate)
                        if os.path.isfile(candidate_path):
                            info[candidate].append(dotted_name)
            for key in deps:
                deps[key].extend(info.get(key, []))
    for key in deps:
        deps[key] = set([n for n in deps[key] if n not in deferred])
    return deps