how to provide globally accessible import

75 views
Skip to first unread message

mike Trienis

unread,
Dec 9, 2021, 12:34:13 PM12/9/21
to Protocol Buffers
Hi,

I'm wondering if it's possible to provide a globally accessible import similar to what you do for google protobuf packages:

```
import "google/protobuf/descriptor.proto";
```

For example,

// current relative path: `path/to/schemas/test_message.proto`
```
syntax="proto2";

import "path/to/schemas/global.proto";

message TestMessage {

    option (custom_option).meta_data_1 = "pipes";

}
```

One major caveat is that when I'm compiling to python bindings, the only way I've managed to get the import paths inserted correctly into `test_message_pb2.py` is to copy `global.proto` to the same path as `test_message.proto` and compiling like:

`protoc --python_out . path/to/schemas/global.proto path/to/schemas/test_message.proto`

This issue describes some of the import pathing issues with Python3:
Any guidance / recommended approach would be appreciated 

Reply all
Reply to author
Forward
0 new messages