-
Notifications
You must be signed in to change notification settings - Fork 3.2k
req: Add warning of not recording VCS info with legacy 'setup.py install' #9208
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add warning of not recording VCS info with legacy 'setup.py install' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -802,18 +802,26 @@ def install( | |
|
|
||
| self.install_succeeded = success | ||
|
|
||
| if success and self.legacy_install_reason == 8368: | ||
| deprecated( | ||
| reason=( | ||
| "{} was installed using the legacy 'setup.py install' " | ||
| "method, because a wheel could not be built for it.".format( | ||
| self.name | ||
| ) | ||
| ), | ||
| replacement="to fix the wheel build issue reported above", | ||
| gone_in=None, | ||
| issue=8368, | ||
| ) | ||
| if success: | ||
| if self.legacy_install_reason == 8368: | ||
| deprecated( | ||
| reason=( | ||
| "{} was installed using the legacy 'setup.py install' " | ||
| "method, because a wheel could not be built for it.".format( | ||
| self.name | ||
| ) | ||
| ), | ||
| replacement="to fix the wheel build issue reported above", | ||
| gone_in=None, | ||
| issue=8368, | ||
| ) | ||
| if self.link.is_vcs: | ||
| logger.warning( | ||
| "Direct URL of package '%s' will not be recorded when " | ||
| "using legacy 'setup.py install'.\n" | ||
| "Consider installing the 'wheel' package.", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Installing the wheel package may not be sufficient, as there are other reason for falling back to |
||
| self.name, | ||
| ) | ||
|
|
||
|
|
||
| def check_invalid_constraint_type(req: InstallRequirement) -> str: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| from pip._vendor.packaging.requirements import Requirement | ||
|
|
||
| from pip._internal.exceptions import InstallationError | ||
| from pip._internal.models.link import Link | ||
| from pip._internal.req.constructors import ( | ||
| install_req_from_line, | ||
| install_req_from_req_string, | ||
|
|
@@ -106,3 +107,26 @@ def test_install_req_from_string_with_comes_from_without_link(self): | |
| assert install_req.link.url == wheel_url | ||
| assert install_req.req.url == wheel_url | ||
| assert install_req.is_wheel | ||
|
|
||
| def test_install_req_vcs_without_wheel_warning(self, caplog): | ||
| """ | ||
| Test to make sure that installing from VCS without wheel generates | ||
| a warning. | ||
| """ | ||
| req = InstallRequirement( | ||
| Requirement("gputil==1.4.0"), | ||
| comes_from=[], | ||
| link=Link("git+https://github.com/llamafilm/gputil") | ||
| ) | ||
|
|
||
| req.source_dir = os.curdir | ||
| req.install([]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhhh, don't do this in a unit test... This has side effects that affect the interpreter it's running in. Specifically, it'll install the package when you run the tests There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the correct way to do it? This is how it was done in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lemme know what you think @pradyunsg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @pradyunsg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the ping! This got buried in my notifications. :( Write an integration test that exercises this code path. Here's an example, that you'll likely need to change the name of the package for. Feel free to add the source code for a minimal reproducer package in def test_install_vcs_something_something_triggers_a_warning(
script,
data,
):
to_install = data.packages.joinpath("a-thing-that-triggers-this")
result = script.pip_install_local(
to_install,
allow_stderr_warning=True,
)
msg = "Direct URL of package 'a-thing-that-triggers-this' will not be recorded when using"
assert msg in result.stderrThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See |
||
|
|
||
| actual = [(r.levelname, r.message) for r in caplog.records] | ||
| expected = ( | ||
| 'WARNING', | ||
| "Direct URL of package 'gputil' will not be recorded when using" | ||
| " legacy 'setup.py install'.\n" | ||
| "Consider installing the 'wheel' package." | ||
| ) | ||
| assert expected in actual | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To better match the condition used to create direct_url.json ?