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

Discard insufficient fork markers #10682

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

konstin
Copy link
Member

@konstin konstin commented Jan 16, 2025

In #10669, a pyproject.toml with requires-python but no environment had a lockfile covering only a subset of the requires-python space:

resolution-markers = [
    "python_full_version >= '3.10' and platform_python_implementation == 'CPython'",
    "python_full_version == '3.9.*'",
    "python_full_version < '3.9'",
]

This marker set is invalid, we have to reject the lockfile. (We can still use the versions though, to avoid churn).

Part 1/2 of #10669

@konstin konstin marked this pull request as draft January 16, 2025 14:43
@konstin konstin assigned konstin and unassigned konstin Jan 16, 2025
@konstin konstin added the bug Something isn't working label Jan 16, 2025
@charliermarsh
Copy link
Member

Once discarded, do we just produce the same lockfile anyway? (If so, does this actually fix anything?)

@konstin
Copy link
Member Author

konstin commented Jan 16, 2025

That's the other half of #10669: the lockfile we're seeing is invalid, it doesn't cover all possible environments. We should never produce a lockfile in this state (fixing #10669), this new branch is error recovery from a buggy state.

This PR exists because i minimized #10669 to this problem by keeping the lockfile, while we still need to fix the problem where we produce this lockfile starting from a pyproject.toml.

@charliermarsh
Copy link
Member

Ok. My question is: does this actually produce the correct lockfile? Or even with this change, are we still producing the incorrect lockfile after invalidating?

@konstin konstin changed the base branch from main to charlie/pypy-req-python January 17, 2025 10:53
@konstin
Copy link
Member Author

konstin commented Jan 17, 2025

If checked that when running uv sync on attrs' uv-lock branch, we warn and fix the markers in the lockfile.

There are two ways to create the lockfile:

A)

git switch uv-lock
uv-this-pr sync

B)

git switch uv-lock
rm uv.lock
uv-this-pr sync

(A) has a slightly larger diff to uv-lock than (B) because we collapse e.g. zipp 3.20.2 and zip 3.21.0 into only zipp 3.20.2. I think this is acceptable for an error recovery branch.

@konstin konstin marked this pull request as ready for review January 17, 2025 11:02
@charliermarsh charliermarsh force-pushed the charlie/pypy-req-python branch from 6cbcccf to e5e8e8f Compare January 17, 2025 15:58
Base automatically changed from charlie/pypy-req-python to main January 17, 2025 16:25
};
// We respect requires-python in addition to the environments the use specified.
environments_union.and(requires_python.to_marker_tree());
if fork_markers_union != environments_union {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do they have to be exactly equal...? Could one be a superset?

Copy link
Member Author

@konstin konstin Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence whether to do an equality check or a contains check, i like the equality check because it should catch more bad markers, but we can already revert that to if fork_markers_union.negate().is_disjoint(environments_union).

Copy link
Member

@charliermarsh charliermarsh Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets do the more conservative thing (contains) for now... I'm just worried that this could have a significant impact and doesn't have a ton of testing, does it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to change this but don't feel confident enough doing it myself, so it may miss this release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@konstin konstin force-pushed the konsti/discard-invalid-fork-markers branch from c9946b6 to 09ca582 Compare January 17, 2025 18:16
@charliermarsh
Copy link
Member

I'll tweak and merge this.

@konstin konstin force-pushed the konsti/discard-invalid-fork-markers branch 2 times, most recently from 568ea23 to 75a28a2 Compare January 20, 2025 09:31
In #10669, a pyproject.toml with requires-python but no environment had a lockfile covering only a subset of the requires-python space:

```toml
resolution-markers = [
    "python_full_version >= '3.10' and platform_python_implementation == 'CPython'",
    "python_full_version == '3.9.*'",
    "python_full_version < '3.9'",
]
```

This marker set is invalid, we have to reject the lockfile. (We can still use the versions though, to avoid churn).
@konstin konstin force-pushed the konsti/discard-invalid-fork-markers branch from 75a28a2 to 7a6e478 Compare January 21, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants