Esempio n. 1
0
 def add_req(subreq, extras_requested):
     sub_install_req = InstallRequirement.from_req(
         str(subreq),
         req_to_install,
         isolated=self.isolated,
         wheel_cache=self.wheel_cache,
     )
     parent_req_name = req_to_install.name
     to_scan_again, add_to_parent = requirement_set.add_requirement(
         sub_install_req,
         parent_req_name=parent_req_name,
         extras_requested=extras_requested,
     )
     if parent_req_name and add_to_parent:
         self._discovered_dependencies[parent_req_name].append(
             add_to_parent)
     more_reqs.extend(to_scan_again)
Esempio n. 2
0
 def add_req(subreq, extras_requested):
     sub_install_req = InstallRequirement.from_req(
         str(subreq),
         req_to_install,
         isolated=self.isolated,
         wheel_cache=self.wheel_cache,
     )
     parent_req_name = req_to_install.name
     to_scan_again, add_to_parent = requirement_set.add_requirement(
         sub_install_req,
         parent_req_name=parent_req_name,
         extras_requested=extras_requested,
     )
     if parent_req_name and add_to_parent:
         self._discovered_dependencies[parent_req_name].append(
             add_to_parent
         )
     more_reqs.extend(to_scan_again)
Esempio n. 3
0
    def _resolve_one(self,
                     requirement_set,
                     req_to_install,
                     ignore_requires_python=False):
        """Prepare a single requirements file.

        :return: A list of additional InstallRequirements to also install.
        """
        # Tell user what we are doing for this requirement:
        # obtain (editable), skipping, processing (local url), collecting
        # (remote url or package name)
        if ignore_requires_python or self.ignore_requires_python:
            self.ignore_compatibility = True

        if req_to_install.constraint or req_to_install.prepared:
            return []

        req_to_install.prepared = True

        # register tmp src for cleanup in case something goes wrong
        requirement_set.reqs_to_cleanup.append(req_to_install)

        abstract_dist = self._get_abstract_dist_for(req_to_install)

        # Parse and return dependencies
        dist = abstract_dist.dist(self.finder)
        try:
            check_dist_requires_python(dist)
        except UnsupportedPythonVersion as err:
            if self.ignore_compatibility:
                logger.warning(err.args[0])
            else:
                raise

        # A huge hack, by Kenneth Reitz.
        try:
            self.requires_python = check_dist_requires_python(dist,
                                                              absorb=False)
        except TypeError:
            self.requires_python = None

        more_reqs = []

        def add_req(subreq, extras_requested):
            sub_install_req = InstallRequirement.from_req(
                str(subreq),
                req_to_install,
                isolated=self.isolated,
                wheel_cache=self.wheel_cache,
            )
            parent_req_name = req_to_install.name
            to_scan_again, add_to_parent = requirement_set.add_requirement(
                sub_install_req,
                parent_req_name=parent_req_name,
                extras_requested=extras_requested,
            )
            if parent_req_name and add_to_parent:
                self._discovered_dependencies[parent_req_name].append(
                    add_to_parent)
            more_reqs.extend(to_scan_again)

        with indent_log():
            # We add req_to_install before its dependencies, so that we
            # can refer to it when adding dependencies.
            if not requirement_set.has_requirement(req_to_install.name):
                available_requested = sorted(
                    set(dist.extras) & set(req_to_install.extras))
                # 'unnamed' requirements will get added here
                req_to_install.is_direct = True
                requirement_set.add_requirement(
                    req_to_install,
                    parent_req_name=None,
                    extras_requested=available_requested,
                )

            if not self.ignore_dependencies:
                if req_to_install.extras:
                    logger.debug(
                        "Installing extra requirements: %r",
                        ','.join(req_to_install.extras),
                    )
                missing_requested = sorted(
                    set(req_to_install.extras) - set(dist.extras))
                for missing in missing_requested:
                    logger.warning('%s does not provide the extra \'%s\'',
                                   dist, missing)

                available_requested = sorted(
                    set(dist.extras) & set(req_to_install.extras))
                for subreq in dist.requires(available_requested):
                    add_req(subreq, extras_requested=available_requested)

                # Hack for deep-resolving extras.
                for available in available_requested:
                    if hasattr(dist, '_DistInfoDistribution__dep_map'):
                        for req in dist._DistInfoDistribution__dep_map[
                                available]:
                            req = InstallRequirement.from_req(
                                str(req),
                                req_to_install,
                                isolated=self.isolated,
                                wheel_cache=self.wheel_cache,
                            )

                            more_reqs.append(req)

            if not req_to_install.editable and not req_to_install.satisfied_by:
                # XXX: --no-install leads this to report 'Successfully
                # downloaded' for only non-editable reqs, even though we took
                # action on them.
                requirement_set.successfully_downloaded.append(req_to_install)

        return more_reqs
Esempio n. 4
0
    def _resolve_one(self, requirement_set, req_to_install, ignore_requires_python=False):
        """Prepare a single requirements file.

        :return: A list of additional InstallRequirements to also install.
        """
        # Tell user what we are doing for this requirement:
        # obtain (editable), skipping, processing (local url), collecting
        # (remote url or package name)
        if ignore_requires_python or self.ignore_requires_python:
            self.ignore_compatibility = True

        if req_to_install.constraint or req_to_install.prepared:
            return []

        req_to_install.prepared = True

        # register tmp src for cleanup in case something goes wrong
        requirement_set.reqs_to_cleanup.append(req_to_install)

        abstract_dist = self._get_abstract_dist_for(req_to_install)

        # Parse and return dependencies
        dist = abstract_dist.dist(self.finder)
        try:
            check_dist_requires_python(dist)
        except UnsupportedPythonVersion as err:
            if self.ignore_compatibility:
                logger.warning(err.args[0])
            else:
                raise

        # A huge hack, by Kenneth Reitz.
        try:
            self.requires_python = check_dist_requires_python(dist, absorb=False)
        except TypeError:
            self.requires_python = None

        more_reqs = []

        def add_req(subreq, extras_requested):
            sub_install_req = InstallRequirement.from_req(
                str(subreq),
                req_to_install,
                isolated=self.isolated,
                wheel_cache=self.wheel_cache,
            )
            parent_req_name = req_to_install.name
            to_scan_again, add_to_parent = requirement_set.add_requirement(
                sub_install_req,
                parent_req_name=parent_req_name,
                extras_requested=extras_requested,
            )
            if parent_req_name and add_to_parent:
                self._discovered_dependencies[parent_req_name].append(
                    add_to_parent
                )
            more_reqs.extend(to_scan_again)

        with indent_log():
            # We add req_to_install before its dependencies, so that we
            # can refer to it when adding dependencies.
            if not requirement_set.has_requirement(req_to_install.name):
                available_requested = sorted(
                    set(dist.extras) & set(req_to_install.extras)
                )
                # 'unnamed' requirements will get added here
                req_to_install.is_direct = True
                requirement_set.add_requirement(
                    req_to_install, parent_req_name=None,
                    extras_requested=available_requested,
                )

            if not self.ignore_dependencies:
                if req_to_install.extras:
                    logger.debug(
                        "Installing extra requirements: %r",
                        ','.join(req_to_install.extras),
                    )
                missing_requested = sorted(
                    set(req_to_install.extras) - set(dist.extras)
                )
                for missing in missing_requested:
                    logger.warning(
                        '%s does not provide the extra \'%s\'',
                        dist, missing
                    )

                available_requested = sorted(
                    set(dist.extras) & set(req_to_install.extras)
                )
                for subreq in dist.requires(available_requested):
                    add_req(subreq, extras_requested=available_requested)

                # Hack for deep-resolving extras.
                for available in available_requested:
                    if hasattr(dist, '_DistInfoDistribution__dep_map'):
                        for req in dist._DistInfoDistribution__dep_map[available]:
                            req = InstallRequirement.from_req(
                                str(req),
                                req_to_install,
                                isolated=self.isolated,
                                wheel_cache=self.wheel_cache,
                            )

                            more_reqs.append(req)

            if not req_to_install.editable and not req_to_install.satisfied_by:
                # XXX: --no-install leads this to report 'Successfully
                # downloaded' for only non-editable reqs, even though we took
                # action on them.
                requirement_set.successfully_downloaded.append(req_to_install)

        return more_reqs