-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add --required-by
option to list
command
#10036
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
Conversation
149c84b
to
c4ff7f9
Compare
The feature looks reasonable to me, although I can’t decide this on my own. Also, you probably need to run the linters locally to weed out some syntax issues; this won’t pass on CI (so I’m not going to approve the run). You can find the instructions here: https://pip.pypa.io/en/stable/development/getting-started/ |
This allows to do something like: ``` $ pip list --required-by mypackage Package Version -------------- -------- asyncpg 0.23.0 httpx 0.18.1 Jinja2 2.11.3 minicli 0.5.0 openpyxl 3.0.7 progressist 0.1.0 PyJWT 2.1.0 roll 0.13.0 ujson 1.35 ``` And yet more usesul in my workflow: ``` $ pip list --required-by mypackage --outdated Package Version Latest Type ---------- ------- ------ ----- Jinja2 2.11.3 3.0.1 wheel ujson 1.35 4.0.2 wheel ```
c4ff7f9
to
353fa51
Compare
I'm going to bikeshed a little on the name. When I read It's not a major point, and I really can't explain my view any better than I just have, but what do others think? On a more substantial point, this isn't the thing I'd find most useful in my workflow. As it stands,
doesn't tell me whether it's safe to upgrade these packages, as it's not checking whether mypackage requires an older version. What I'd find more useful (but it's a lot harder to do) is "list outdated packages which nothing else depends on" as a substitute for an "upgrade all" command. But I don't object to this feature, I just think it might need some documentation explaining the limitations and the intended usage. |
Also, I just checked. In addition, I just found out about |
I want to say I'm not a huge fan of adding "query" options to Something was started in #8008, and I'll eventually come back to it if no-one else beats me to it, although I can't commit on any kind of timeline. I don't mean to block this PR if other maintainers think it is useful, though. |
I actually agree with this comment. And in fact, for queries that don't interact with PyPI, this doesn't even need to be blocked on getting added to pip at all. The bare bones of the proposed from importlib.metadata import distribution, PackageNotFoundError
from packaging.requirements import Requirement
import sys
for name in sys.argv[1:]:
d = distribution(name)
reqs = d.metadata.get_all("Requires-Dist")
for r in reqs:
req = Requirement(r)
if req.marker and not req.marker.evaluate({"extra": ""}):
continue
dist = distribution(req.name)
print(req.name, dist.version) Obviously, adding the |
Closing this out, since this PR has merge conflicts and the general concensus amongst the maintainers seems to be that this isn't the direction we want to take If there's still interest in doing this, I encourage the interested folks to file a new PR for this. :) |
This allows to do something like:
And yet more usesul in my workflow:
That may be a naive approach, but I'll let you judge about that :)