def get_finder(
        self,
        sources: list[RepositoryConfig] | None = None,
        ignore_compatibility: bool | NotSetType = NotSet,
        minimal_version: bool = False,
        env_spec: EnvSpec | None = None,
    ) -> Generator[unearth.PackageFinder]:
        """Return the package finder of given index sources.

        :param sources: a list of sources the finder should search in.
        :param ignore_compatibility: (DEPRECATED)whether to ignore the python version
            and wheel tags.
        :param minimal_version: whether to find the minimal version of the package.
        :param env_spec: the environment spec to filter the packages.
        """
        from pdm.models.finder import PDMPackageFinder

        if sources is None:
            sources = self.project.sources
        if not sources:
            raise PdmUsageError(
                "You must specify at least one index in pyproject.toml or config.\n"
                "The 'pypi.ignore_stored_index' config value is "
                f"{self.project.config['pypi.ignore_stored_index']}"
            )
        if ignore_compatibility is not NotSet:  # pragma: no cover
            deprecation_warning(
                "`ignore_compatibility` argument is deprecated, pass in `env_spec` instead.\n",
                stacklevel=2,
            )
        else:
            ignore_compatibility = False

        if env_spec is None:
            if ignore_compatibility:  # pragma: no cover
                env_spec = self.allow_all_spec
            else:
                env_spec = self.spec

        finder = PDMPackageFinder(
            session=self.session,
            env_spec=env_spec,
            no_binary=self._setting_list("PDM_NO_BINARY", "resolution.no-binary"),
            only_binary=self._setting_list("PDM_ONLY_BINARY", "resolution.only-binary"),
            prefer_binary=self._setting_list("PDM_PREFER_BINARY", "resolution.prefer-binary"),
            respect_source_order=self.project.pyproject.settings.get("resolution", {}).get(
                "respect-source-order", False
            ),
            verbosity=self.project.core.ui.verbosity,
            minimal_version=minimal_version,
            exclude_newer_than=self.project.core.state.exclude_newer,
        )
        finder.sources.clear()
        for source in sources:
            assert source.url
            if source.type == "find_links":
                finder.add_find_links(source.url)
            else:
                finder.add_index_url(source.url)
        yield finder
Return the package finder of given index sources.

        :param sources: a list of sources the finder should search in.
        :param ignore_compatibility: (DEPRECATED)whether to ignore the python version
            and wheel tags.
        :param minimal_version: whether to find the minimal version of the package.
        :param env_spec: the environment spec to filter the packages.
        
src/pdm/environments/base.py