Skip to content
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

Support specifying which packages and versions to update. #409

Merged
merged 3 commits into from
Nov 17, 2016

Conversation

nnja
Copy link
Contributor

@nnja nnja commented Nov 11, 2016

The current behavior for pip-compile --upgrade updates all requirements. This becomes complicated for large .in files when that's not always the desired behavior.

This patch introduces a new flag, --upgrade-package which has the following features:

Upgrade only a specific package to the latest version:

$ pip-compile --upgrade-package flask

Upgrade a specific package to a specific version:

$ pip-compile --upgrade-package flask==0.10.1 

Upgrade multiple packages at a time, by passing in multiple arguments:

$ pip-compile --upgrade-package flask==0.10.1 --upgrade-package werkzeug

Additional output was added when using the --verbose flag to list which packages were updated, and to which version.

@nnja nnja force-pushed the support_single_package_upgrade branch from 1fdf4b7 to 42a2f1c Compare November 15, 2016 22:36
@nnja
Copy link
Contributor Author

nnja commented Nov 15, 2016

Pushed some updates - the build is now green, except for https://travis-ci.org/nvie/pip-tools/jobs/176202798 piptools/utils.py:22:1: E305 expected 2 blank lines after class or function definition, found 1 which seems unrelated to my changes, since I have not modified utils.py

@nnja nnja force-pushed the support_single_package_upgrade branch from 42a2f1c to 5f3f9e9 Compare November 15, 2016 23:11
@nvie
Copy link
Member

nvie commented Nov 17, 2016

I love this idea, thanks for your contribution, @nnja!

The way pip-compile's default invocation vs the upgrade logic works is quite clever. Basically, what happens is that if an output file exists (and the --upgrade flag is not given), it will add the current pins from the output file into the list of input specs, and then "just" trigger the resolver.

In that light, using this new -P <pkg> flag really means "don't perform the above-mentioned process for this package <pkg>". Or, when a pin is given: "ditto, but also pin it to <pin> while you're at it".

So really all you need to do here is to filter the list of "existing pins" and therefore discarding those explicit pins in favor of the stuff provided on the command line. I've gone ahead and implemented that in d0dd26a, which as you can see does not require any special handling for this feature at all. (It's perhaps best to look at the net-diff against master for the best view of the total change required for this.)

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants