Conversation
Rework the way commands are defined, loaded and ran in pip: - Commands are instantiated on demand in pip.main(). - A command 'registry' - mapping of command names to command classes in pip.commands.__init__. - Remove deferred command module loading.
Monkey-patching 'pip.util.dist_in_site_packages' through 'sitecustomize.py' in 'tests/test_user_site.py' wasn't working unless the fully qualitifed path to 'dist_in_site_packages' was used.
pip/req.py
Outdated
There was a problem hiding this comment.
This is a very unfortunate addition, but the monkey patching in tests/test_user_site.py wasn't working otherwise.
There was a problem hiding this comment.
It'd be good to figure out a way around this.
There was a problem hiding this comment.
hey @gvalkov , I'll try to create the user site test problems you were having and see if there's a workaround.
|
We do appreciate your effort - but all the maintainers are volunteers and personally my time is pretty limited at the moment. I'll do a first pass and leave comments. Generally reviews will be easier if you do small incremental pull requests, it's easier to follow the refactoring and comment on - if you look at Issue #511 for an example for where we've done this before. |
|
@gvalkov , can you spell out for us why the 3 bullet pt refactors above are needed or preferred for what's coming? I appreciate the links to the other pkg manager help outputs, and like I said before in a previous pull, I'm attracted to the new help format for pip you link to, that would follow this. |
|
Certainly. Here goes:
Hope this wall of text was helpful. Unfortunately, the changes are all very intertwined and I didn't see a way of breaking them down any further :\ |
|
pip is older than argparse (at least, older than PEP 389), so it's not surprising that it does not use it. |
patch dist_in_site_packages for user_site tests
|
My bad, I should have |
pip/commands/help.py
Outdated
There was a problem hiding this comment.
Please no bare exception handling.
|
This looks good in general, but please fix the issues I've commented on before we merge this. |
`pip help <misspelled>` should return the same error message as `pip <misspelled>`, namely: ERROR: unknown command "enstall" - maybe you meant "install"
|
looks like you handled jannis' comments. I want to merge this, but 2 more thoughts:
|
|
@qwcode, I've aligned the command and option lists, but I'm not sure how to go about passing the main parser to individual commands. My 30 minute go at it today resulted in some serious build breakage - will look into it these days. At this point I feel like porting all option handling to argparse, instead of having to deal with the current implementation (It really isn't such a crazy idea :) |
|
We need to support 2.5 and 2.6, I guess we could depend on http://code.google.com/p/argparse/ I'd say if all the minor nits are done lets get this in and iterate on it so we can start improving the commands. |
|
sure, let's merge with this, and iterate more in the next pull. I confirmed the indent fixes. but @gvalkov , see my rework-commands-v2_options branch. I'm hesitant to add a dependency on argparse, since it means a change to virtualenv. |
|
@gvalkov just noticed you're not in the authors file. I'll add you. |
Hi, refactoring guy here again. I decided to resurrect my command line rework patch from a while ago (~9 months). Basically I think that pip's command line interface is not up to par with what you'd expect from Python's flagship package manager. It's quite possibly, the worst one of all package managers that fall in the same category (see gem, npm, luarocks, cabal), in terms of command line look & feel.
In pull requests #463 and #533, I proposed turning pip's cli from this to this. It's not a big improvement, but it's a start. Unfortunately, I just couldn't bring myself to implementing these without refactoring a few things first and while the general vibe about these changes was positive, very few of the them made it in.
This pull request contains just the refactoring portion of the previous two requests (no ui). To summarize:
pip.__init__.main(). Seepip.commands.__init__.baseparser.parser- the globalOptionParserinstance. EachCommandinstance now receives the mainOptionParseras its first argument. The mainOptionParseritself is created withbaseparser.create_main_parser().pip.__init__by taking option parsing out ofmain().Hopefully, this pull request is more 'reviewable' and 'mergeable' than the previous two. The interface changes themselves will come in another round of commits, probably right after I get some assurance that this will get pulled in. Pip has a long pull queue and while this may not be the most important pull of all, some refactoring and attention to detail is long due.
I hope I'm not coming out as arrogant, but I'm concerned about wasting any more time on this, given your track record of accepting my contributions :) I really just want Python to have an excellent package manager.
Cheers,