Skip to content
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

[Question] How to use protoc instead of buf in a python project #283

Closed
jmspereira opened this issue Dec 16, 2024 · 1 comment
Closed

[Question] How to use protoc instead of buf in a python project #283

jmspereira opened this issue Dec 16, 2024 · 1 comment
Labels
Question Questions about the project or libraries

Comments

@jmspereira
Copy link

jmspereira commented Dec 16, 2024

Hey everyone, sorry if this issue is duplicated, but I didn't find any that addressed the entire process or I am missing something when using protoc instead of buf. I have a python project with a set of protobuf files, I am compiling them with:

protoc <protobuf-files> 
-I/usr/local/include/protovalidate  
--fatal_warnings 
--python_out=/<outpath> 
--pyi_out=/<outpath>  
--include_imports 
--descriptor_set_out=<outpath>/gen

Where the include_imports and the descriptor_set_out were set as documented. However, even when I define the PYTHONPATH to the gen file, still does not work, with the following error:

>>> import protovalidate
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venv/lib/python3.11/site-packages/protovalidate/__init__.py", line 15, in <module>
    from protovalidate import validator
  File "/venv/lib/python3.11/site-packages/protovalidate/validator.py", line 19, in <module>
    from buf.validate import expression_pb2  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'buf'

This is likely because this is not generating the validate_pb2.py but a binary file. So, what is the correct process in order to use protovalidate with protoc in a python project?

Thanks!

@jmspereira jmspereira added the Bug Something isn't working label Dec 16, 2024
@rodaine rodaine added Question Questions about the project or libraries and removed Bug Something isn't working labels Dec 17, 2024
@rodaine rodaine changed the title [BUG] How to use protoc instead of buf in a python project How to use protoc instead of buf in a python project Dec 17, 2024
@jmspereira jmspereira changed the title How to use protoc instead of buf in a python project [Question] How to use protoc instead of buf in a python project Dec 18, 2024
@jmspereira
Copy link
Author

Discussed in bufbuild/protovalidate-python#237

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Questions about the project or libraries
Projects
None yet
Development

No branches or pull requests

2 participants