1
1
Fork 0
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:
briantracy 2021-07-11 20:40:43 -07:00 committed by GitHub
parent f2ce7741ab
commit 37a2b12a21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

1
news/9915.feature.rst Normal file
View file

@ -0,0 +1 @@
Add a special error message when users forget the ``-r`` flag when installing.

View file

@ -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}")

View file

@ -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'],