protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

python plugin can generate invalid python file names.

Open james-lawrence opened this issue 1 year ago • 6 comments

forgive me if i'm missing something obvious python is a language I rarely touch by choice so I might be missing something trivial.

What version of protobuf and what language are you using? Version: 5.27.2 Language: python

What operating system (Linux, Windows, ...) and version?

uname -a
Linux 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64 GNU/Linux

What runtime / compiler are you using (e.g., python version or gcc version) Python 3.12.4, setup a virtual env following the grpc quick start guide.

What did you do? Steps to reproduce the behavior:

  1. create a proto file with the name example.service.proto
  2. generate python code using the proto file. .egpyenv/bin/python -m grpc_tools.protoc --python_out=. --pyi_out=. --grpc_python_out=. example.service.proto
  3. generated code will be named example.service_pb2.py and example.service_pb2_grpc.py respectively.
  4. can't import these files easily in python making them hard to use.

What did you expect to see generated code that was usable. manually renaming the proto files is a possibility but the point of IDL tools is to handle these langauge specific divergent behaviors.

What did you see instead? hard to import generated code.

james-lawrence avatar Aug 26 '24 19:08 james-lawrence

@james-lawrence Can you provide a little more information about what was hard about importing these files?

googleberg avatar Sep 09 '24 03:09 googleberg

try importing a python file with periods in the filename, python doesn't allow it as periods are used as path separators.

for example: if you import the following it'll look for the file foo/bar/example.py not file.bar.example.py which is what the protoc plugin generates with a proto file names foo.bar.example.proto. afiak there is no way to import a file named as such in python, but that could just be my lack of knowledge of python's behaviors for imports.

import foo.bar.example

james-lawrence avatar Sep 09 '24 11:09 james-lawrence

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Jan 03 '25 10:01 github-actions[bot]

bump.

james-lawrence avatar Jan 03 '25 12:01 james-lawrence

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Apr 04 '25 10:04 github-actions[bot]

bump

james-lawrence avatar Apr 05 '25 02:04 james-lawrence

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago. This issue will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Sep 20 '25 10:09 github-actions[bot]

bump still an issue.

james-lawrence avatar Sep 22 '25 12:09 james-lawrence