-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Subcommand to display all "top level" requirements #12185
Comments
Closing due to no expressed interest from Pip maintainers. IMO without this it's not really possible to write useful tools that call Pip from the command line to do custom resolution tasks. So instead one has to import Pip directly in Python, which is fragile but the only practical solution, as we can see from the pip-tools repo, |
@notatallshaw the Json installation report does mention top level requirements. Combined with --dry-run and --no-deps does this help with your use case? |
@sbidoul Not really, that still downloads wheels and also builds sdists |
True. That is solvable, though and there is ongoing work in that direction. On second read, I think I don't quite understand why this use case is important. If a tool can call |
I agree with @sbidoul - how is this anything more than a requirements file parser? |
Update: in the original issue it was me who suggested a subcommand. But that was prefaced with the condition “if it’s so complicated…”. But I still don’t believe it is complicated - it’s just a list of command line arguments and requirement files, which can be parsed very simplistically. There’s no need for the full complexity of pip’s parsing or option handling. |
Pip can source top level requirements from the command line and requirement files simultaneously. There can be multiple requirements files, they can be nested infinitely and use other weird options, the behavior may change in the future as new features are added. Only Pip can reproduce it's own behavior, that's why wrapping tools import Pip directly. |
🤷 The use case for this was "write a script to install a set of requirements one by one". That script doesn't need to support all of the complexity that pip supports. Is there another use case that I'm missing? To put this another way, you are correct that there's no interest from the pip maintainers (at least, not from me) for exposing pip's command line syntax, and the parsing of that syntax, as a service for other tools to use. I would absolutely not hold pip's CLI syntax up as a good example for other tools to copy - quite the opposite, I'd strongly encourage them to design their own UI using a more modern framework than optparse. And nesting and "weird options" in requirement files are just another aspect of requirements files not being standardised. We should standardise something rather than encouraging more extensive use of requirements files. |
As you say I already closed this, I don't understand why there are follow up questions after it's closed. As you probably know I'm extremely familiar with Pip and understand the viability of various solutions for my use cases. For me the effort to justify this is greater than importing Pip's internal functions and pinning my Pip version, like pip-tools does. The only consequence is it means I won't share any of my tools publicly because I can't depend on any interface Pip has to the extent I would want to support other users who would benefit from my tooling. |
Mostly because you closed it saying there was no interest from the pip maintainers, which had 2 effects (for me, at least):
Plus, of course, once a discussion starts, I get emails, so I tend to follow up more 🙂 Anyway, I don't want to waste anyone's time with extended discussion on a closed issue, so I'll stop here. |
What's the problem this feature will solve?
This subcommand would be useful for wrapping Pip in a script or debugging user issues.
Describe the solution you'd like
Given a command like
pip requirements ...
where the...
is the usual ways to provide requirements like you would withdownload
orinstall
subcommands, Pip would collect all the local requirements it normally does and print them out.Alternative Solutions
Additional context
Came up while discussing #12160.
With this feature implemented it would be significantly more trivial to make a third party package that implemented the behavior described by wrapping Pip and calling it from a subprocess instead of hacking the internal Pip API.
Code of Conduct
The text was updated successfully, but these errors were encountered: