-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Implement a "pip upgrade" command #3194
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
39e0f27
Implement a "pip upgrade" command
jkseppan 2de71f0
Formatting
jkseppan ac1cfee
A more meaningful name
jkseppan d62535b
Improve RequirementSet API
jkseppan 9e57de7
Fix an inconsistency
jkseppan a18c32a
Add a --recursive option to pip upgrade
jkseppan f030eeb
Allow pip upgrade to overwrite target
jkseppan 7b32fab
Deprecate pip install --upgrade
jkseppan 4ee0fc3
Add some documentation
jkseppan f6619df
Update all the tests to use pip upgrade
jkseppan 90a50ff
Put back expect_stderr=True
jkseppan 476cfd3
Use pip upgrade in another test
jkseppan 3cc01f0
Expect SSLContext warnings with pip upgrade
jkseppan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,7 @@ def prep_for_dist(self): | |
class RequirementSet(object): | ||
|
||
def __init__(self, build_dir, src_dir, download_dir, upgrade=False, | ||
upgrade_recursive=False, | ||
ignore_installed=False, as_egg=False, target_dir=None, | ||
ignore_dependencies=False, force_reinstall=False, | ||
use_user_site=False, session=None, pycompile=True, | ||
|
@@ -153,6 +154,11 @@ def __init__(self, build_dir, src_dir, download_dir, upgrade=False, | |
unpacking. | ||
:param wheel_cache: The pip wheel cache, for passing to | ||
InstallRequirement. | ||
:param upgrade: Whether the direct requirements (and possibly their | ||
dependencies) should be upgraded. | ||
:param upgrade_recursive: Whether all dependencies should be upgraded | ||
even if not needed to satisfy new lower bounds of directly | ||
upgraded packages. | ||
""" | ||
if session is None: | ||
raise TypeError( | ||
|
@@ -167,6 +173,7 @@ def __init__(self, build_dir, src_dir, download_dir, upgrade=False, | |
# the wheelhouse output by 'pip wheel'. | ||
self.download_dir = download_dir | ||
self.upgrade = upgrade | ||
self.upgrade_recursive = upgrade_recursive | ||
self.ignore_installed = ignore_installed | ||
self.force_reinstall = force_reinstall | ||
self.requirements = Requirements() | ||
|
@@ -227,6 +234,7 @@ def add_requirement(self, install_req, parent_req_name=None): | |
install_req.use_user_site = self.use_user_site | ||
install_req.target_dir = self.target_dir | ||
install_req.pycompile = self.pycompile | ||
install_req.direct = (parent_req_name is None) | ||
if not name: | ||
# url or path requirement w/o an egg fragment | ||
self.unnamed_requirements.append(install_req) | ||
|
@@ -366,14 +374,16 @@ def _check_skip_installed(self, req_to_install, finder): | |
req_to_install.check_if_exists() | ||
if req_to_install.satisfied_by: | ||
skip_reason = 'satisfied (use --upgrade to upgrade)' | ||
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. This should say |
||
if self.upgrade: | ||
upgrade_this = self.upgrade and ( | ||
self.upgrade_recursive or req_to_install.direct) | ||
if upgrade_this: | ||
best_installed = False | ||
# For link based requirements we have to pull the | ||
# tree down and inspect to assess the version #, so | ||
# its handled way down. | ||
if not (self.force_reinstall or req_to_install.link): | ||
try: | ||
finder.find_requirement(req_to_install, self.upgrade) | ||
finder.find_requirement(req_to_install, upgrade_this) | ||
except BestVersionAlreadyInstalled: | ||
skip_reason = 'up-to-date' | ||
best_installed = True | ||
|
@@ -408,6 +418,8 @@ def _prepare_file(self, finder, req_to_install): | |
return [] | ||
|
||
req_to_install.prepared = True | ||
upgrade_this = self.upgrade and ( | ||
self.upgrade_recursive or req_to_install.direct) | ||
|
||
if req_to_install.editable: | ||
logger.info('Obtaining %s', req_to_install) | ||
|
@@ -469,7 +481,7 @@ def _prepare_file(self, finder, req_to_install): | |
"can delete this. Please delete it and try again." | ||
% (req_to_install, req_to_install.source_dir) | ||
) | ||
req_to_install.populate_link(finder, self.upgrade) | ||
req_to_install.populate_link(finder, upgrade_this) | ||
# We can't hit this spot and have populate_link return None. | ||
# req_to_install.satisfied_by is None here (because we're | ||
# guarded) and upgrade has no impact except when satisfied_by | ||
|
@@ -524,7 +536,7 @@ def _prepare_file(self, finder, req_to_install): | |
if not self.ignore_installed: | ||
req_to_install.check_if_exists() | ||
if req_to_install.satisfied_by: | ||
if self.upgrade or self.ignore_installed: | ||
if upgrade_this or self.ignore_installed: | ||
# don't uninstall conflict if user install and | ||
# conflict is not user install | ||
if not (self.use_user_site and not | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
again, maybe bikeshedding, here, but I want the RequirementSet properties to be meaningful for the long term
what we're doing here is keeping the general word "upgrade" to refer to the old style "recursive upgrade", and then tacking on a new property "upgrade_direct" for the new non-recursive type.
maybe that allows for a smaller PR diff, but I care more about readability.
to me the most readable properties for the Set would be:
upgrade
: whether it's an upgrade of any kindupgrade_recursive
: is it recursive or not