-
Notifications
You must be signed in to change notification settings - Fork 6
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
[BUG] ImportError on import buf/validate #96
Comments
Hey @o-murphy! Thanks for the report. Can you give more details about the steps you're running and the errors you are seeing? |
I believe I have the same problem.
my buf.gen.yaml:
I generate my python proto files into my module:
This puts the generated python classes and the buf validate files in
so if I wanted to importe the validate_pb2.py I need to do
but protovalidate wants (Disclaimer, to make generated python proto classes work with this module src layout you have to do a sed rewrite trick - I was just hoping that I do not need some other hacks for validation. Also here it would be trickier since I would have to rewrite protovalidate module ) |
Got it! Yes this is a known issue (also reported on buf) for protobuf python generation in general. There are some workarounds in that linked thread, but without a rewrite or a |
I want to distribute my project to PyPi, I use Now I have a temporary sollution: copying the # protovalidate.validator.py
from a7p.buf.validate import expression_pb2 # type: ignore
from a7p.protovalidate.internal import constraints as _constraints
from a7p.protovalidate.internal import extra_func Can you provide me a way how can I set the top-level of my library to protovalidate module to get the valid import of Look at this project tree please |
Description
if we generate the python sources with buf and --include-imports flag, the protovalidate tries to import buf locally, but if we want to make generated sources a part of other module, the protovalidate raises ImportError on buf/validate import, so we need modify the protovalidate module sources to set where we want to import buf/validate
The text was updated successfully, but these errors were encountered: