Skip to content

Commit

Permalink
amazing hack
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
  • Loading branch information
kennethreitz committed Sep 29, 2017
1 parent 5da4af3 commit ae4591b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
27 changes: 27 additions & 0 deletions pipenv/patched/pip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ def __init__(self, find_links, index_urls, allow_all_prereleases=False,
# The Session we'll use to make requests
self.session = session

# Kenneth's Hack.
self.extra = None

# The valid tags to check potential found wheel candidates against
self.valid_tags = get_supported(
versions=versions,
Expand Down Expand Up @@ -202,6 +205,30 @@ def add_dependency_links(self, links):
)
self.dependency_links.extend(links)

def get_extras_links(self, links):
requires = []
extras = {}

current_section = None

for link in links:
if not link:
current_section = None

if not current_section:
if not (link.startswith('[')):
requires.append(link)
else:
current_section = link[1:-1]
extras[current_section] = []
else:
extras[current_section].append(link)

return extras




@staticmethod
def _sort_locations(locations, expand_dir=False):
"""
Expand Down
34 changes: 32 additions & 2 deletions pipenv/patched/pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def dist(self, finder):
finder.add_dependency_links(
dist.get_metadata_lines('dependency_links.txt')
)
if dist.has_metadata('requires.txt'):
dist.extra = finder.get_extras_links(
dist.get_metadata_lines('requires.txt')
)

return dist

def prep_for_dist(self):
Expand Down Expand Up @@ -679,16 +684,21 @@ def add_req(subreq, extras_requested):
isolated=self.isolated,
wheel_cache=self._wheel_cache,
)

more_reqs.extend(self.add_requirement(
sub_install_req, req_to_install.name,
extras_requested=extras_requested))

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

# self.add_requirement(req_to_install)
if not ignore_dependencies:
if (req_to_install.extras):
logger.debug(
Expand All @@ -707,9 +717,23 @@ def add_req(subreq, extras_requested):
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(
str(req),
req_to_install,
isolated=self.isolated,
wheel_cache=self._wheel_cache,
)

more_reqs.append(req)

# cleanup tmp src
self.reqs_to_cleanup.append(req_to_install)

Expand All @@ -719,7 +743,13 @@ def add_req(subreq, extras_requested):
# action on them.
self.successfully_downloaded.append(req_to_install)

return more_reqs
# print(self.requirements)
# print()
# print(more_reqs)
# print('\n')
# print('\n')

return self.requirements.values() + more_reqs

def cleanup_files(self):
"""Clean up files, remove builds."""
Expand Down
6 changes: 4 additions & 2 deletions pipenv/patched/piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ def get_dependencies(self, ireq):
self.source_dir,
download_dir=download_dir,
wheel_download_dir=self._wheel_download_dir,
session=self.session)
self._dependencies_cache[ireq] = reqset._prepare_file(self.finder, ireq)
session=self.session,
ignore_installed=True)
result = reqset._prepare_file(self.finder, ireq)
self._dependencies_cache[ireq] = result
return set(self._dependencies_cache[ireq])

def get_hashes(self, ireq):
Expand Down
3 changes: 3 additions & 0 deletions pipenv/patched/piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def _iter_dependencies(self, ireq):
elif ireq.markers:
for dependency in self.repository.get_dependencies(ireq):
yield dependency
elif ireq.extras:
for dependency in self.repository.get_dependencies(ireq):
yield dependency
return
elif not is_pinned_requirement(ireq):
raise TypeError('Expected pinned or editable requirement, got {}'.format(ireq))
Expand Down

0 comments on commit ae4591b

Please sign in to comment.