danielgtaylor / danielgtaylor/python-betterproto

Make generated stubs import already existing stubs from another project

Open
#425 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
1.8k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

I currently have a project defining some common message types called `common_proto` and it is installed using git with pip into another project as a package.

Inside the package, the proto files are found inside the `proto` folder and are imported inside my other proto file where I wanna use them like `import "common_proto/proto/common.proto"`. I have added my `site_packages` folder to `--proto_path` and generting everything works fine.

While the normal protobuf compiler for python correctly takes that proto and the already generated protobuf python when it imports it, betterproto generates the python files instead of using the ones available in the same folder which are available as `common_proto/proto/csm/common/__init__.py` where the package path is the one defined in `common.proto` like `package csm.common`.

I know this is probably not the most elegant setup for the folder structure, but it was the one we used with the old protobuf compiler.

Would it be possible for the betterproto compiler to look in the same folder with the proto file to search for the python module if it exists? Would help avoid regenerating the files and allow shipping proto files in other modules to be reused.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.