Skip to content

Add pylock select function#1092

Merged
brettcannon merged 14 commits intopypa:mainfrom
sbidoul:pylock_select-sbi
Mar 26, 2026
Merged

Add pylock select function#1092
brettcannon merged 14 commits intopypa:mainfrom
sbidoul:pylock_select-sbi

Conversation

@sbidoul
Copy link
Copy Markdown
Member

@sbidoul sbidoul commented Feb 15, 2026

This is WIP. Main missing part is handling of dependency groups and extras. And tests of course.

Comments are from PEP 751 Installation section.

closes #1087

Comment thread src/packaging/pylock_select.py Outdated
Comment thread src/packaging/pylock_select.py Outdated
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Feb 15, 2026

/cc @brettcannon

@sbidoul sbidoul force-pushed the pylock_select-sbi branch 5 times, most recently from 699543d to 77ce285 Compare February 16, 2026 22:28
Comment thread src/packaging/pylock.py Outdated
Comment thread src/packaging/pylock.py Outdated
Comment thread src/packaging/pylock.py Outdated
@sbidoul sbidoul force-pushed the pylock_select-sbi branch 2 times, most recently from f52e9cf to 9112d47 Compare February 21, 2026 11:43
Comment thread src/packaging/pylock.py
continue

# #. If :ref:`pylock-packages-requires-python` is specified, check if it is
# satisfied; an error MUST be raised if it isn't.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@brettcannon why is it an error if a package requires-python is not satisfied? Should it not be skipped in that case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's for when https://packaging.python.org/en/latest/specifications/pylock-toml/#requires-python has been satisfied but somehow a specific package claims otherwise. When I wrote that I'm sure my brain was assuming requires-python would be set if packages.requires-python was set.

Comment thread src/packaging/pylock.py Outdated
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Feb 28, 2026

Except for the wheel file name discovery and validation mechanism (waiting for #1095) this should be complete and ready for review.

@sbidoul sbidoul force-pushed the pylock_select-sbi branch 3 times, most recently from 5eeca07 to ff14bd4 Compare March 7, 2026 10:58
@sbidoul sbidoul marked this pull request as ready for review March 7, 2026 11:00
Comment thread tests/pylock/pylock.spec-example.toml
@sbidoul sbidoul force-pushed the pylock_select-sbi branch from 7891b69 to a0256b2 Compare March 21, 2026 13:46
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Mar 21, 2026

I tweaked the requires-python checks. Awaiting maintainers input on #1110 (comment) to finalize this.

@brettcannon
Copy link
Copy Markdown
Member

@sbidoul is there some other PR you want to see merged, or are you ready for me to merge this?

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Mar 24, 2026

@sbidoul is there some other PR you want to see merged, or are you ready for me to merge this?

@brettcannon as you prefer. If #1110 is merged first I'll update this one. If this one is merged first then I'll do another PR to use the selector when #1110 is merged.

@brettcannon
Copy link
Copy Markdown
Member

@sbidoul I just merged @1110 .

@sbidoul sbidoul force-pushed the pylock_select-sbi branch from 399be36 to 9f20a3c Compare March 26, 2026 17:52
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Mar 26, 2026

And I integrated the compatible tags selector.

In 9f20a3c I relaxed the typing of create_compatible_tags_selector a bit to accept an Iterable instead of a Collection.

So all is done and clean here, I think. The only bits that I don't like are the type casts around Environment, but I couldn't find a way to please mypy.

@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Mar 26, 2026

And a test had to be updated following the stricter validation in #1114.

@brettcannon brettcannon merged commit e938536 into pypa:main Mar 26, 2026
56 checks passed
@brettcannon
Copy link
Copy Markdown
Member

@sbidoul thanks so much for working on this! Hopefully this helps unblock pip from installing from a lock file.

@sbidoul sbidoul deleted the pylock_select-sbi branch March 26, 2026 18:53
@sbidoul
Copy link
Copy Markdown
Member Author

sbidoul commented Mar 26, 2026

That was fun. I'll now see what I can do in pip. That might be a bit more hairy.

ngoldbaum pushed a commit to ngoldbaum/packaging that referenced this pull request Apr 1, 2026
This was referenced Apr 13, 2026
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.

Add a function to find what to install from a pylock.toml

2 participants