diff --git a/pipenv/core.py b/pipenv/core.py index 4c154d37..83d99a0b 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1413,9 +1413,8 @@ def pip_install( ignore_hashes = False line = None # Try installing for each source in project.sources. - if requirement.index: + if not index and requirement.index: index = requirement.index - extra_indexes = [] if index and not extra_indexes: extra_indexes = list(project.sources) extra_indexes = list(filter(lambda d: d['name'] == requirement.index, extra_indexes)) @@ -1462,7 +1461,8 @@ def pip_install( pip_command.extend(["-r", vistir.path.normalize_path(r)]) elif line: pip_command.extend(line) - pip_command.extend(prepare_pip_source_args(sources)) + pip_source_args = prepare_pip_source_args(sources) + pip_command.extend(pip_source_args) if project.s.is_verbose(): click.echo(f"$ {cmd_list_to_shell(pip_command)}", err=True) cache_dir = Path(project.s.PIPENV_CACHE_DIR) diff --git a/pipenv/patched/notpip/_internal/index/collector.py b/pipenv/patched/notpip/_internal/index/collector.py index 98ac9d2e..7167ddc1 100644 --- a/pipenv/patched/notpip/_internal/index/collector.py +++ b/pipenv/patched/notpip/_internal/index/collector.py @@ -445,15 +445,18 @@ class LinkCollector: self, session: PipSession, search_scope: SearchScope, + index_lookup: dict = None, ) -> None: self.search_scope = search_scope self.session = session + self.index_lookup = index_lookup if index_lookup else {} @classmethod def create( cls, session: PipSession, options: Values, - suppress_no_index: bool = False + suppress_no_index: bool = False, + index_lookup: dict = None, ) -> "LinkCollector": """ :param session: The Session to use to make requests. @@ -472,10 +475,10 @@ class LinkCollector: find_links = options.find_links or [] search_scope = SearchScope.create( - find_links=find_links, index_urls=index_urls, + find_links=find_links, index_urls=index_urls, index_lookup=index_lookup ) link_collector = LinkCollector( - session=session, search_scope=search_scope, + session=session, search_scope=search_scope, index_lookup=index_lookup ) return link_collector diff --git a/pipenv/patched/notpip/_internal/models/search_scope.py b/pipenv/patched/notpip/_internal/models/search_scope.py index 4b700407..d21a5005 100644 --- a/pipenv/patched/notpip/_internal/models/search_scope.py +++ b/pipenv/patched/notpip/_internal/models/search_scope.py @@ -20,13 +20,14 @@ class SearchScope: Encapsulates the locations that pip is configured to search. """ - __slots__ = ["find_links", "index_urls"] + __slots__ = ["find_links", "index_urls", "index_lookup"] @classmethod def create( cls, find_links: List[str], index_urls: List[str], + index_lookup: dict = None, ) -> "SearchScope": """ Create a SearchScope object after normalizing the `find_links`. @@ -60,15 +61,18 @@ class SearchScope: return cls( find_links=built_find_links, index_urls=index_urls, + index_lookup=index_lookup ) def __init__( self, find_links: List[str], index_urls: List[str], + index_lookup: dict = None, ) -> None: self.find_links = find_links self.index_urls = index_urls + self.index_lookup = index_lookup if index_lookup else {} def get_formatted_locations(self) -> str: lines = [] @@ -123,4 +127,7 @@ class SearchScope: loc = loc + '/' return loc - return [mkurl_pypi_url(url) for url in self.index_urls] + index_urls = self.index_urls + if project_name in self.index_lookup: + index_urls = [self.index_lookup[project_name]] + return [mkurl_pypi_url(url) for url in index_urls] diff --git a/pipenv/utils.py b/pipenv/utils.py index 0c7a17d7..10e94bd8 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -804,6 +804,14 @@ class Resolver: options=self.pip_options, session=self.session ) + index_mapping = {} + for source in self.sources: + index_mapping[source['name']] = source['url'] + alt_index_lookup = {} + for req_name, index in self.index_lookup.items(): + alt_index_lookup[req_name] = index_mapping[index] + self._finder._link_collector.index_lookup = alt_index_lookup + self._finder._link_collector.search_scope.index_lookup = alt_index_lookup return self._finder @property @@ -827,7 +835,6 @@ class Resolver: from pipenv.vendor.pip_shims import shims pip_options = self.pip_options - print("pip_options", pip_options) pip_options.extra_index_urls = [] if self._parsed_constraints is None: self._parsed_constraints = shims.parse_requirements( @@ -887,9 +894,10 @@ class Resolver: from pipenv.vendor.pip_shims.shims import InstallationError from pipenv.exceptions import ResolutionFailure + constraints = self.constraints with temp_environ(), self.get_resolver() as resolver: try: - results = resolver.resolve(self.constraints, check_supported_wheels=False) + results = resolver.resolve(constraints, check_supported_wheels=False) except InstallationError as e: raise ResolutionFailure(message=str(e)) else: