Skip to content

pyproject: precisely constrain python-version to 3.11 or later #966

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

Merged

Conversation

thoughtpolice
Copy link
Contributor

uv pointed this out to me while running glasgow; the ~= operator for dependency resolution is a bit subtle; it basically allows you to "round up" the upper bound of a dependency but it does so based on the least-sigificant-specified component of a version number.

Basically that means ~=3.11 is equal to "from any version 3.11 up-to < 4.0" but ~3.11.0 means "from any version 3.11.0 up-to < 3.12.0"; in this case we want the second one.

Funny enough, fixing this and re-generating the lockfile actually looks like it correctly removes many wheel entries for other major python versions like 3.12. So that's a good sign that uv's hint was correct.

@thoughtpolice
Copy link
Contributor Author

Please note that I am an absolute heretic and generated this change with uv after looking at how cron.yml worked :)

PDM_LOCKFILE=pdm.min.lock uv run --with pdm pdm lock --group :all --strategy direct_minimal_versions

So please just give a quick look over the lock file. In particular it added a lot of groups clauses that weren't there before? I'm not sure why; maybe a consequence of the constrained version? Or maybe it's because the version of pdm I used is different than the one setup-pdm@v4 uses in CI? I guess it will get overwritten anyway when the cron workflow executes, but I'm just curious as to why...

@whitequark
Copy link
Member

whitequark commented Jul 21, 2025

To be clear we do support 3.12 and 3.13 and (optimistically) everything up to but not including Python 4.

@thoughtpolice
Copy link
Contributor Author

Oh, I see! OK, then the original constraint is correct. Maybe there's a way to do this that isn't ugly that uv won't bark about. I'll put this in draft for a minute.

@thoughtpolice thoughtpolice marked this pull request as draft July 21, 2025 00:18
@whitequark
Copy link
Member

Try >=3.11,<4

@whitequark
Copy link
Member

Oh and to regenerate the lockfile you run pdm update-pdm.min.lock

@thoughtpolice thoughtpolice force-pushed the aseipp/push-xllmslmzvprw branch from 1f535f5 to 7c62cab Compare July 21, 2025 00:26
@thoughtpolice thoughtpolice marked this pull request as ready for review July 21, 2025 00:26
@whitequark whitequark enabled auto-merge July 21, 2025 00:26
@thoughtpolice
Copy link
Contributor Author

Yep; I figured out that inherit_metadata somehow got specified as a strategy which caused the group = ... thing, so turning that off and regenerating worked fine. I think this should be good!

@whitequark
Copy link
Member

Thanks!

`uv` pointed this out to me while running glasgow; the `~=` operator
for dependency resolution is a bit subtle; it basically allows you to
"round up" the upper bound of a dependency but it does so based on the
least-sigificant-specified component of a version number.

Basically that means `~=3.11` is equal to "from any version 3.11 up-to
< 4.0" but `~3.11.0` means "from any version 3.11.0 up-to < 3.12.0".

We want the first, but it's apparently subtle enough that uv (probably
correctly, tbh) warns about it. Let's write it in a more unambiguous
way.

Signed-off-by: Austin Seipp <[email protected]>
@whitequark
Copy link
Member

That's an amusing branch name you've got.

auto-merge was automatically disabled July 21, 2025 00:27

Head branch was pushed to by a user without write access

@thoughtpolice thoughtpolice force-pushed the aseipp/push-xllmslmzvprw branch from 7c62cab to 44998dd Compare July 21, 2025 00:27
@thoughtpolice
Copy link
Contributor Author

I also went ahead and rewrote the commit message too, so it's actually accurate. Don't care too much about the PR name, though.

And the PR name is from Jujutsu which I help maintain :) It's really good and you should try it. You might even end up falling in love with it for making version control so nice /shameless-plug

@thoughtpolice thoughtpolice changed the title pyproject: precisely constrain python-version to 3.11.x pyproject: constrain python-version in a less ambiguous way Jul 21, 2025
@whitequark
Copy link
Member

I keep meaning to look into jj, yeah!

@whitequark whitequark enabled auto-merge July 21, 2025 00:29
@whitequark whitequark changed the title pyproject: constrain python-version in a less ambiguous way pyproject: precisely constrain python-version to 3.11 or later Jul 21, 2025
@whitequark whitequark added this pull request to the merge queue Jul 21, 2025
Merged via the queue into GlasgowEmbedded:main with commit 3d58d71 Jul 21, 2025
12 checks passed
@thoughtpolice thoughtpolice deleted the aseipp/push-xllmslmzvprw branch July 21, 2025 00:49
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