danielgtaylor / danielgtaylor/python-betterproto
Make generated stubs import already existing stubs from another project
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 234
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Reproduce the package layout described with `common_proto/proto/common.proto`, the importing proto, `--proto_path`, and the existing `common_proto/proto/csm/common/__init__.py`. Start by tracing how imported protos are resolved, then verify that an existing generated Python module is reused rather than regenerated and that imports still work across the two projects.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100