-
Notifications
You must be signed in to change notification settings - Fork 9
Add re2 as optional dependency #346
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
stefanvanburen
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.
lgtm, one nit on testextra but otherwise exactly what I was envisioning
Makefile
Outdated
|
|
||
| .PHONY: testextra | ||
| testextra: | ||
| uv pip install .[re2] |
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.
I think we want to avoid uv pip, and instead do something like uv sync --extra re2?: https://docs.astral.sh/uv/concepts/projects/sync/#syncing-optional-dependencies
| from protovalidate.internal.extra_func import cel_matches_re, cel_matches_re2 | ||
|
|
||
| _USE_RE2 = True | ||
| spec = importlib.util.find_spec("re2") |
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.
protovalidate/internal/extra_func.py
Outdated
|
|
||
| _USE_RE2 = True | ||
| try: | ||
| import re2 # type: ignore |
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.
one other minor thing, if we want: could install the google-re2-stubs package as a dev dependency, which would give us type info for re2 (and we could nix the ignore here).
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.
(published by the same person who had asked for re2 compatibility, here: #145)
This adds
re2as an optional dependency to protovalidate-python. With this configured, users can choose to optionally install re2 if they explicit re2 functionality.For example
pip install protovalidate[re2]Note that while CEL requires re2 as part of the spec, our current version of cel-python (v0.2.0) doesn't. We are unable to upgrade cel-python beyond v0.2.0 at this point due to some outstanding issues, so since re2 now supports Python 3.13, we're adding it as an optional dep directly to protovalidate-python rather than the re2 workaround we had previously implemented.