mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Special case warning for requirements.txt install (#9915)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
This commit is contained in:
parent
f2ce7741ab
commit
37a2b12a21
3 changed files with 14 additions and 0 deletions
1
news/9915.feature.rst
Normal file
1
news/9915.feature.rst
Normal file
|
@ -0,0 +1 @@
|
|||
Add a special error message when users forget the ``-r`` flag when installing.
|
|
@ -551,6 +551,13 @@ class Factory:
|
|||
req_disp,
|
||||
", ".join(versions) or "none",
|
||||
)
|
||||
if str(req) == "requirements.txt":
|
||||
logger.info(
|
||||
"HINT: You are attempting to install a package literally "
|
||||
'named "requirements.txt" (which cannot exist). Consider '
|
||||
"using the '-r' flag to install the packages listed in "
|
||||
"requirements.txt"
|
||||
)
|
||||
|
||||
return DistributionNotFound(f"No matching distribution found for {req}")
|
||||
|
||||
|
|
|
@ -143,6 +143,12 @@ def test_install_special_extra(script):
|
|||
) in result.stderr, str(result)
|
||||
|
||||
|
||||
def test_install_requirements_no_r_flag(script):
|
||||
'''Beginners sometimes forget the -r and this leads to confusion'''
|
||||
result = script.pip('install', 'requirements.txt', expect_error=True)
|
||||
assert 'literally named "requirements.txt"' in result.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"extra_to_install, simple_version", [
|
||||
['', '3.0'],
|
||||
|
|
Loading…
Reference in a new issue