-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Full implementation of --keep-outdated
#3304
Merged
Merged
Changes from 8 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
566e1c1
Fix accidentally-shortened installation timeouts
techalchemy 052c5b8
Create sample implementation for keep outdated functionality
techalchemy fb99f71
Add PEEP to outline behavior
techalchemy d3bcd83
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 5b8b10d
Fully functional `--keep-outdated` implementation
techalchemy 97962d9
PEEP update and resolver fix
techalchemy 76a5e29
Merge branch 'master' into feature/keep-outdated-peep
techalchemy de24a5f
Merge branch 'master' into feature/keep-outdated-peep
techalchemy de20227
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 83f5791
Merge branch 'feature/keep-outdated-peep' of github.com:pypa/pipenv i…
techalchemy df712cc
Bugfixes for set resolution
techalchemy 3feeaa7
Merge branch 'master' into feature/keep-outdated-peep
ncoghlan 552d127
Merge with updates
techalchemy 698dfb8
Port over changes that were overwritten
techalchemy a33ad9d
Update utils to work with patch
techalchemy 1fcafb8
Re-integrate changes from `keep_outdated`
techalchemy 9c0bac1
add updated requirementslib
techalchemy 7798cbe
Update lockfile
techalchemy fae1dba
Update setup.py to keep pytest pinned below 4.0
techalchemy adaf442
Fix missing import of `ConnectionError`
techalchemy fbdf933
Fix test script
techalchemy 86ca58c
Merge branch 'bugfix/3148' into feature/keep-outdated-peep
techalchemy 6604712
Create requirements inside spinner for better UX
techalchemy f69aaf3
Merge branch 'bugfix/3148' into feature/keep-outdated-peep
techalchemy 5383db1
Update lockfile
techalchemy 1207e3d
Update keep outdated implementation with new pipenv code
techalchemy 3e96bfe
Fix pip version check code
techalchemy b9f7852
Update lockfile
techalchemy ecb3352
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 93b65fe
Remove old constraint line from locking function
techalchemy 7413f2f
Update lockfile and switch to the correct python version for tests
techalchemy 6552e8d
Add tests for `--keep-outdated`
techalchemy 0cc3e25
Rename peep to `004`
techalchemy 0382e0c
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 3131e2f
Rename peep to 005 to make room for kenneth's peep
techalchemy 93019f3
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 83b1f12
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 6382f51
Merge branch 'master' into feature/keep-outdated-peep
techalchemy e16608c
sort pytest markers by length
techalchemy 0b5826e
Fix typo in PEEP
techalchemy c7b2a52
Merge branch 'master' into feature/keep-outdated-peep
techalchemy ea9129a
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 1b84c6b
Merge branch 'master' into feature/keep-outdated-peep
techalchemy 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 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# PEEP-005: Do Not Remove Entries from the Lockfile When Using `--keep-outdated` | ||
|
||
**PROPOSED** | ||
|
||
This PEEP describes a change that would retain entries in the Lockfile even if they were not returned during resolution when the user passes the `--keep-outdated` flag. | ||
|
||
☤ | ||
|
||
The `--keep-outdated` flag is currently provided by Pipenv for the purpose of holding back outdated dependencies (i.e. dependencies that are not newly introduced). This proposal attempts to identify the reasoning behind the flag and identifies a need for a project-wide scoping. Finally, this proposal outlines the expected behavior of `--keep-outdated` under the specified circumstances, as well as the required changes to achieve full implementation. | ||
|
||
## Retaining Outdated Dependencies | ||
|
||
The purpose of retaining outdated dependencies is to allow the user to introduce a new package to their environment with a minimal impact on their existing environment. In an effort to achieve this, `keep_outdated` was proposed as both a flag and a Pipfile setting [in this issue](https://github.com/pypa/pipenv/issues/1255#issuecomment-354585775), originally described as follows: | ||
|
||
> pipenv lock --keep-outdated to request a minimal update that only adjusts the lock file to account for Pipfile changes (additions, removals, and changes to version constraints)... and pipenv install --keep-outdated needed to request only the minimal changes required to satisfy the installation request | ||
|
||
However, the current implementation always fully re-locks, rather than only locking the new dependencies. As a result, dependencies in the `Pipfile.lock` with markers for a python version different from that of the running interpreter will be removed, even if they have nothing to do with the current changeset. For instance, say you have the following dependency in your `Pipfile.lock`: | ||
|
||
```json | ||
{ | ||
"default": { | ||
"backports.weakref": { | ||
"hashes": [...], | ||
"version": "==1.5", | ||
"markers": "python_version<='3.4'" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
If this lockfile were to be re-generated with Python 3, even with `--keep-outdated`, this entry would be removed. This makes it very difficult to maintain lockfiles which are compatible across major python versions, yet all that would be required to correct this would be a tweak to the implementation of `keep-outdated`. I believe this was the goal to begin with, but I feel this behavior should be documented and clarified before moving forward. | ||
|
||
## Desired Behavior | ||
|
||
1. The only changes that should occur in `Pipfile.lock` when `--keep-outdated` is passed should be changes resulting from new packages added or pin changes in the project `Pipfile`; | ||
2. Existing packages in the project `Pipfile.lock` should remain in place, even if they are not returned during resolution; | ||
3. New dependencies should be written to the lockfile; | ||
4. Conflicts should be resolved as outlined below. | ||
|
||
## Conflict Resolution | ||
|
||
If a conflict should occur due to the presence in the `Pipfile.lock` of a dependency of a new package, the following steps should be undertaken before alerting the user: | ||
|
||
1. Determine whether the previously locked version of the dependency meets the constraints required of the new package; if so, pin that version; | ||
2. If the previously locked version is not present in the `Pipfile` and is not a dependency of any other dependencies (i.e. has no presence in `pipenv graph`, etc), update the lockfile with the new version; | ||
3. If there is a new or existing dependency which has a conflict with existing entries in the lockfile, perform an intermediate resolution step by checking: | ||
a. If the new dependency can be satisfied by existing installs; | ||
b. Whether conflicts can be upgraded without affecting locked dependencies; | ||
c. If locked dependencies must be upgraded, whether those dependencies ultimately have any dependencies in the `Pipfile`; | ||
d. If a traversal up the graph lands in the `Pipfile`, create _abstract dependencies_ from the `Pipfile` entries and determine whether they will still be satisfied by the new version; | ||
e. If a new pin is required, ensure that any subdependencies of the newly pinned dependencies are therefore also re-pinned (simply prefer the updated lockfile instead of the cached version); | ||
4. Raise an Exception alerting the user that they either need to do a full lock or manually pin a version. | ||
|
||
## Necessary Changes | ||
|
||
In order to make these changes, we will need to modify the dependency resolution process. Overall, locking will require the following implementaiton changes: | ||
|
||
1. The ability to restore any entries that would otherwise be removed when the `--keep-outdated` flag is passed. The process already provides a caching mechanism, so we simply need to restore missing cache keys; | ||
2. Conflict resolution steps: | ||
a. Check an abstract dependency/candidate against a lockfile entry; | ||
b. Requirements mapping for each dependency in the environment to determine if a lockfile entry is a descendent of any other entries; | ||
|
||
|
||
Author: Dan Ryan <[email protected]> |
This file contains 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 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 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.
Typo in "implementaiton"