Example #1
0
    def _solve(self, use_latest=None):
        self._branches.append(self._package.python_versions)

        locked = {}
        for package in self._locked.packages:
            locked[package.name] = DependencyPackage(package.to_dependency(),
                                                     package)

        try:
            result = resolve_version(self._package,
                                     self._provider,
                                     locked=locked,
                                     use_latest=use_latest)

            packages = result.packages
        except CompatibilityError as e:
            return self.solve_in_compatibility_mode(e.constraints,
                                                    use_latest=use_latest)
        except SolveFailure as e:
            raise SolverProblemError(e)

        graph = self._build_graph(self._package, packages)

        depths = []
        final_packages = []
        for package in packages:
            category, optional, marker, depth = self._get_tags_for_package(
                package, graph)

            if marker is None:
                marker = AnyMarker()
            if marker.is_empty():
                continue

            package.category = category
            package.optional = optional
            package.marker = marker

            depths.append(depth)
            final_packages.append(package)

        return final_packages, depths
Example #2
0
    def _solve(self, use_latest=None):
        locked = {}
        for package in self._locked.packages:
            locked[package.name] = package

        try:
            result = resolve_version(
                self._package, self._provider, locked=locked, use_latest=use_latest
            )

            packages = result.packages
        except CompatibilityError as e:
            return self.solve_in_compatibility_mode(
                e.constraints, use_latest=use_latest
            )
        except SolveFailure as e:
            raise SolverProblemError(e)

        graph = self._build_graph(self._package, packages)

        depths = []
        for package in packages:
            category, optional, python, platform, depth = self._get_tags_for_package(
                package, graph
            )
            depths.append(depth)

            package.category = category
            package.optional = optional

            # If requirements are empty, drop them
            requirements = {}
            if python is not None and python != "*":
                requirements["python"] = python

            if platform is not None and platform != "*":
                requirements["platform"] = platform

            package.requirements = requirements

        return packages, depths
Example #3
0
    def _solve(self, use_latest=None):
        locked = {}
        for package in self._locked.packages:
            locked[package.name] = package

        try:
            result = resolve_version(self._package,
                                     self._provider,
                                     locked=locked,
                                     use_latest=use_latest)

            packages = result.packages
        except CompatibilityError as e:
            return self.solve_in_compatibility_mode(e.constraints,
                                                    use_latest=use_latest)
        except SolveFailure as e:
            raise SolverProblemError(e)

        graph = self._build_graph(self._package, packages)

        depths = []
        for package in packages:
            category, optional, python, platform, depth = self._get_tags_for_package(
                package, graph)
            depths.append(depth)

            package.category = category
            package.optional = optional

            # If requirements are empty, drop them
            requirements = {}
            if python is not None and python != "*":
                requirements["python"] = python

            if platform is not None and platform != "*":
                requirements["platform"] = platform

            package.requirements = requirements

        return packages, depths
Example #4
0
    def _solve(self, use_latest=None):
        if self._provider._overrides:
            self._overrides.append(self._provider._overrides)

        locked = {}
        for package in self._locked.packages:
            locked[package.name] = DependencyPackage(package.to_dependency(),
                                                     package)

        try:
            result = resolve_version(self._package,
                                     self._provider,
                                     locked=locked,
                                     use_latest=use_latest)

            packages = result.packages
        except OverrideNeeded as e:
            return self.solve_in_compatibility_mode(e.overrides,
                                                    use_latest=use_latest)
        except SolveFailure as e:
            raise SolverProblemError(e)

        graph = self._build_graph(self._package, packages)

        depths = []
        final_packages = []
        for package in packages:
            category, optional, depth = self._get_tags_for_package(
                package, graph)

            package.category = category
            package.optional = optional

            depths.append(depth)
            final_packages.append(package)

        return final_packages, depths
Example #5
0
    def solve(self, use_latest=None):  # type: (...) -> List[Operation]
        provider = Provider(self._package, self._pool, self._io)
        locked = {}
        for package in self._locked.packages:
            locked[package.name] = package

        try:
            result = resolve_version(self._package,
                                     provider,
                                     locked=locked,
                                     use_latest=use_latest)
        except SolveFailure as e:
            raise SolverProblemError(e)

        packages = result.packages
        requested = self._package.all_requires

        for package in packages:
            graph = self._build_graph(self._package, packages)
            category, optional, python, platform = self._get_tags_for_package(
                package, graph)

            package.category = category
            package.optional = optional

            # If requirements are empty, drop them
            requirements = {}
            if python is not None and python != "*":
                requirements["python"] = python

            if platform is not None and platform != "*":
                requirements["platform"] = platform

            package.requirements = requirements

        operations = []
        for package in packages:
            installed = False
            for pkg in self._installed.packages:
                if package.name == pkg.name:
                    installed = True
                    # Checking version
                    if package.version != pkg.version:
                        operations.append(Update(pkg, package))
                    else:
                        operations.append(
                            Install(package).skip("Already installed"))

                    break

            if not installed:
                operations.append(Install(package))

        # Checking for removals
        for pkg in self._locked.packages:
            remove = True
            for package in packages:
                if pkg.name == package.name:
                    remove = False
                    break

            if remove:
                skip = True
                for installed in self._installed.packages:
                    if installed.name == pkg.name:
                        skip = False
                        break

                op = Uninstall(pkg)
                if skip:
                    op.skip("Not currently installed")

                operations.append(op)

        requested_names = [r.name for r in self._package.all_requires]

        return sorted(
            operations,
            key=lambda o: (
                1 if o.package.name in requested_names else 0,
                o.package.name,
            ),
        )