示例#1
0
 def sort_dependencies(self, dependencies: List[Dependency],
                       activated: DependencyGraph,
                       conflicts: Dict[str, List[Conflict]]):
     return sorted(dependencies,
                   key=lambda d: [
                       0 if activated.vertex_named(d.name).payload else 1, 0
                       if d.allows_prereleases() else 1, 0
                       if d.name in conflicts else 1, 0
                       if activated.vertex_named(d.name).payload else len(
                           self.search_for(d))
                   ])
示例#2
0
    def is_requirement_satisfied_by(self, requirement: Dependency,
                                    activated: DependencyGraph,
                                    package: Package) -> bool:
        """
        Determines whether the given requirement is satisfied by the given
        spec, in the context of the current activated dependency graph.
        """
        if isinstance(requirement, Package):
            return requirement == package

        if not requirement.accepts(package):
            return False

        if package.is_prerelease() and not requirement.allows_prereleases():
            vertex = activated.vertex_named(package.name)

            if not any([r.allows_prereleases() for r in vertex.requirements]):
                return False

        return self._package.python_constraint.matches(
            package.python_constraint)