Skip to content

Commit

Permalink
Merge pull request #2142 from derwolfe/extras-user-warn-2138
Browse files Browse the repository at this point in the history
warn user when requested extra does not exist - 2138
  • Loading branch information
dstufft committed Mar 16, 2015
2 parents b1fe2cd + 97b03f4 commit cccefe1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,20 @@ def prepare_files(self, finder):
)

if not self.ignore_dependencies:
for subreq in dist.requires(
req_to_install.extras):
if self.has_requirement(
subreq.project_name):
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):
if self.has_requirement(subreq.project_name):
# FIXME: check for conflict
continue
subreq = InstallRequirement(
Expand Down
52 changes: 52 additions & 0 deletions tests/functional/test_install_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,55 @@ def test_no_extras_uninstall(script):
# openid should not be uninstalled
initools_folder = script.site_packages / 'openid'
assert initools_folder not in result2.files_deleted, result.files_deleted


def test_nonexistent_extra_warns_user_no_wheel(script, data):
"""
A warning is logged telling the user that the extra option they requested
does not exist in the project they are wishing to install.
This exercises source installs.
"""
result = script.pip(
'install', '--no-use-wheel', '--no-index',
'--find-links=' + data.find_links,
'simple[nonexistent]', expect_stderr=True,
)
assert (
"Unknown 3.0 does not provide the extra 'nonexistent'"
in result.stdout
)


def test_nonexistent_extra_warns_user_with_wheel(script, data):
"""
A warning is logged telling the user that the extra option they requested
does not exist in the project they are wishing to install.
This exercises wheel installs.
"""
result = script.pip(
'install', '--use-wheel', '--no-index',
'--find-links=' + data.find_links,
'simplewheel[nonexistent]', expect_stderr=True,
)
assert (
"simplewheel 2.0 does not provide the extra 'nonexistent'"
in result.stdout
)


def test_nonexistent_options_listed_in_order(script, data):
"""
Warn the user for each extra that doesn't exist.
"""
result = script.pip(
'install', '--use-wheel', '--no-index',
'--find-links=' + data.find_links,
'simplewheel[nonexistent, nope]', expect_stderr=True,
)
msg = (
" simplewheel 2.0 does not provide the extra 'nonexistent'\n"
" simplewheel 2.0 does not provide the extra 'nope'"
)
assert msg in result.stdout

0 comments on commit cccefe1

Please sign in to comment.