Skip to content

Commit

Permalink
Use _build_package_finder to make PackageFinder
Browse files Browse the repository at this point in the history
Turns out Command._build_package_finder avaiable since 8.1.1
  • Loading branch information
atugushev committed Jul 24, 2019
1 parent 06e2203 commit 072e72b
Showing 1 changed file with 7 additions and 36 deletions.
43 changes: 7 additions & 36 deletions piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
FAVORITE_HASH,
InstallCommand,
Link,
PackageFinder,
PyPI,
RequirementSet,
Resolver as PipResolver,
Expand Down Expand Up @@ -74,10 +73,13 @@ def __init__(self, pip_args, build_isolation=False):
# Use pip's parser for pip.conf management and defaults.
# General options (find_links, index_url, extra_index_url, trusted_host,
# and pre) are deferred to pip.
self.command = InstallCommand()
self.options, _ = self.command.parse_args(pip_args)
self.session = self.command._build_session(self.options)
self.finder = self._make_package_finder()
command = InstallCommand()
self.options, _ = command.parse_args(pip_args)

self.session = command._build_session(self.options)
self.finder = command._build_package_finder(
options=self.options, session=self.session
)

# Caches
# stores project_name => InstallationCandidate mappings for all
Expand All @@ -95,37 +97,6 @@ def __init__(self, pip_args, build_isolation=False):
self._download_dir = fs_str(os.path.join(CACHE_DIR, "pkgs"))
self._wheel_download_dir = fs_str(os.path.join(CACHE_DIR, "wheels"))

def _make_package_finder(self):
"""
Create a PackageFinder.
"""
# Since pip 19.2 PackageFinder has been refactored
if get_pip_version() < parse_version("19.2"):
index_urls = [self.options.index_url] + self.options.extra_index_urls
if self.options.no_index:
index_urls = []

kwargs = {
"find_links": self.options.find_links,
"index_urls": index_urls,
"trusted_hosts": self.options.trusted_hosts,
"allow_all_prereleases": self.options.pre,
"session": self.session,
}

# pip 19.0 has removed process_dependency_links
# from the PackageFinder constructor
if get_pip_version() < parse_version("19.0"):
kwargs[
"process_dependency_links"
] = self.options.process_dependency_links

return PackageFinder(**kwargs)
else:
return self.command._build_package_finder(
options=self.options, session=self.session
)

def freshen_build_caches(self):
"""
Start with fresh build/source caches. Will remove any old build
Expand Down

0 comments on commit 072e72b

Please sign in to comment.