Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn user when requested extra does not exist - 2138 #2142

Merged
merged 30 commits into from
Mar 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8900f4f
add tests back in
derwolfe Dec 30, 2014
deabed5
log an error when an extra is requested that doesn't exist
derwolfe Dec 30, 2014
91f8010
logging working a bit better
derwolfe Dec 31, 2014
fec9f4f
working on adding tests. It looks like the case of multiple extras no…
derwolfe Dec 31, 2014
53f3346
phrasing
derwolfe Dec 31, 2014
89bff4a
Merge branch 'develop' into extras-user-warn-2138
derwolfe Feb 21, 2015
b079184
trying to tease out dist and requires information
derwolfe Feb 24, 2015
8266863
find missing packages first
derwolfe Feb 24, 2015
db50fe6
naming and return type
derwolfe Feb 24, 2015
6c5edf5
fix indentation
derwolfe Feb 24, 2015
c5d331b
warning showing correctly
derwolfe Feb 24, 2015
5fcf2d6
fix tests; still need to get the version number
derwolfe Feb 24, 2015
5d3d8ab
tests working, need coverage on two new fucntions
derwolfe Feb 24, 2015
2e30c47
Cleanup the functional tests, return a tuple instead of list.
derwolfe Feb 25, 2015
cb1962e
shorten line
derwolfe Feb 25, 2015
8a09436
fix formatting in tests, comments
derwolfe Feb 25, 2015
d3e207e
add unit tests for missing and available functions
derwolfe Feb 25, 2015
19cf33e
spacing
derwolfe Feb 25, 2015
8d0cd56
make _missing_extras and _available_extras staticmethods
derwolfe Feb 25, 2015
70351bb
Use the new staticmethods
derwolfe Feb 25, 2015
ee9a7cd
Add missing RequirementSet
derwolfe Feb 25, 2015
5e62ad9
Move tests in TestRequirementsSet
derwolfe Feb 25, 2015
86e3300
switch to using a tuple wrapping a generator
derwolfe Feb 25, 2015
50237f4
move missing extras functional tests back into test_install_extras
derwolfe Feb 26, 2015
704223d
remove assignement
derwolfe Feb 26, 2015
f38e100
revert newline
derwolfe Feb 26, 2015
4dfbd2e
spacing, sort sets prior to pushing into logger, dist.requires
derwolfe Feb 26, 2015
3a1a45a
make splitting of lines/endings consistent /sigmavirus24
derwolfe Mar 11, 2015
55585d0
nonexistant/nonexistent - msabramo comment
derwolfe Mar 11, 2015
97b03f4
fix test names, non_existant/nonexistent
derwolfe Mar 11, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions pip/req/req_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,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