-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Fix lock updates for locks with sdist bystanders. #2325
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
__version__ = "2.1.156" | ||
__version__ = "2.1.157" | ||
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,80 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import print_function | ||
|
||
import itertools | ||
import os.path | ||
|
||
from pex.pep_440 import Version | ||
from pex.pep_503 import ProjectName | ||
from pex.resolve.locked_resolve import FileArtifact | ||
from pex.resolve.lockfile import json_codec | ||
from pex.resolve.resolved_requirement import Pin | ||
from pex.typing import TYPE_CHECKING | ||
from testing.cli import run_pex3 | ||
|
||
if TYPE_CHECKING: | ||
from typing import Any | ||
|
||
|
||
def test_update_sdists_not_updated(tmpdir): | ||
# type: (Any) -> None | ||
|
||
constraints = os.path.join(str(tmpdir), "constraints.txt") | ||
with open(constraints, "w") as fp: | ||
print("ansicolors<1.1.8", file=fp) | ||
print("cowsay<6", file=fp) | ||
|
||
lock = os.path.join(str(tmpdir), "lock.json") | ||
|
||
def assert_lock(*pins): | ||
# type: (*Pin) -> None | ||
|
||
lockfile = json_codec.load(lock) | ||
assert 1 == len(lockfile.locked_resolves) | ||
locked_resolve = lockfile.locked_resolves[0] | ||
locked_requirements = { | ||
locked_req.pin: tuple(locked_req.iter_artifacts()) | ||
for locked_req in locked_resolve.locked_requirements | ||
} | ||
assert set(pins) == set(locked_requirements) | ||
assert all( | ||
isinstance(artifact, FileArtifact) and artifact.is_source | ||
for artifact in itertools.chain.from_iterable(locked_requirements.values()) | ||
) | ||
|
||
run_pex3( | ||
"lock", | ||
"create", | ||
"--no-wheel", | ||
"--constraints", | ||
constraints, | ||
"ansicolors", | ||
"cowsay", | ||
"--indent", | ||
"2", | ||
"-o", | ||
lock, | ||
).assert_success() | ||
assert_lock( | ||
Pin(ProjectName("ansicolors"), Version("1.1.7")), Pin(ProjectName("cowsay"), Version("5.0")) | ||
) | ||
|
||
# N.B.: Pre-fix this test would lead to an artifact comparison assertion for cowsay, which is | ||
# expected to be unmodified by the lock update. | ||
# | ||
# E Traceback (most recent call last): | ||
# E File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/result.py", line 105, in catch | ||
# E return func(*args, **kwargs) | ||
# E ^^^^^^^^^^^^^^^^^^^^^ | ||
# E File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/resolve/lockfile/updater.py", line 320, in update_resolve | ||
# E assert updated_requirement.artifact == locked_requirement.artifact | ||
# E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
# E AssertionError | ||
# E Encountered 1 error updating /tmp/pytest-of-jsirois/pytest-8/test_update_sdists_not_updated0/lock.json: | ||
# E 1.) cp311-cp311-manylinux_2_35_x86_64: | ||
run_pex3("lock", "update", "-v", "-p", "ansicolors<1.1.9", lock).assert_success() | ||
assert_lock( | ||
Pin(ProjectName("ansicolors"), Version("1.1.8")), Pin(ProjectName("cowsay"), Version("5.0")) | ||
) |
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.
Wouldn't you normally bump this (and edit the CHANGES) in a separate release prep PR? Is this a rebasing error, or deliberate?
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.
This is deliberate. I paused this time and asked myself if there was a good reason to keep these separate, and in the case of a single change release, I couldn't think of a good enough reason.