-
Notifications
You must be signed in to change notification settings - Fork 422
Update check_dependencies to support markers
#19110
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
Conversation
A regression test for the issue we were seeing in #19071 (comment)
| return any( | ||
| extra in DEV_EXTRAS and req.marker.evaluate(_marker_environment(extra)) | ||
| for extra in marker_extras | ||
| ) |
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 looks similar to the logic in _marker_applies_for_any_extra(...)
Although we have an extra extra in DEV_EXTRAS condition to satisfy. And we can't just separate things.
Just a note and I think this is fine ⏩
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.
Yes, it's a bit of a shame. But the only ideal way to combine them would be adding a boolean argument to the function signature, and that feels dirtier than the two (simple) methods IMO.
| @@ -0,0 +1 @@ | |||
| Allow Synapse's runtime dependency checking code to take packaging markers (i.e. `python <= 3.14`) into account when checking dependencies. No newline at end of file | |||
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.
Nothing seems too crazy. And the background from the PR description makes sense. I haven't made sure all of the pieces here are aligning in terms of giving a complete picture but I assume the tests cover this.
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.
That, and the fact that the linked Pydantic v2 PR now passes CI won me over.
anoadragon453
left a comment
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.
Thanks for the review @MadLittleMods! 🦄
| return any( | ||
| extra in DEV_EXTRAS and req.marker.evaluate(_marker_environment(extra)) | ||
| for extra in marker_extras | ||
| ) |
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.
Yes, it's a bit of a shame. But the only ideal way to combine them would be adding a boolean argument to the function signature, and that feels dirtier than the two (simple) methods IMO.
| @@ -0,0 +1 @@ | |||
| Allow Synapse's runtime dependency checking code to take packaging markers (i.e. `python <= 3.14`) into account when checking dependencies. No newline at end of file | |||
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.
That, and the fact that the linked Pydantic v2 PR now passes CI won me over.
|
CI failures are due to flaky tests. |
This PR addresses an issue that came up during #19071. It allowed CI to pass on that PR's branch.
The Problem
@V02460 had added the following to
pyprojects.toml:then the
tests-olddepsCI job started failing with:tests-olddepsuses Python 3.9 andpydantic==2.8.0, which should have been fine according topyproject.toml. However, thecheck_dependencies.check_requirementsmethod raised the above. This is because it didn't takepythoninto account at all, and failed when it readversion = "~= 2.12".Python Packaging Background
The
pythonbit in the snippet above is actuallypoetrysyntax. It translates to the following PEP 508 environment "marker" syntax:python_version < "3.14" is a "marker", and a specific dependency (i.e. requirement) can have multiple (i.e.(sys_platform != 'win32') and (python_version >= '3.10')`).In addition to markers, we have "extras", which we're more familiar with. You can specify an extra identifier, such as "postgres" when installing
pip install matrix-synapse[postgres]and it'll install extra dependencies specifically for using Synapse with postgres.Markers can also include extras as a conditional, stating that a particular requirement only applies when the user has asked for a particular marker. For example:
You'll notice we have some boolean logic here (and, or, etc.). The python packaging code represents a "marker" on a requirement as a Marker Tree. For example:
becomes:
requirement.markerin the code is actually an object representing this tree. i.e. it includes all the conditions for a given requirement.A "marker environment" is the environment that a particular marker is evaluated in. Parts of the environment are: what version of Python is the user using, what OS are they on, what extras did they ask for, etc. Markers are "evaluated" for whether they apply according to this environment.
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.