0
IntelliJ IDEAが生成されたprotobufソースをPythonで認識するのに苦労しています。IntelliJ IDEAがbazel生成のpython protobufsを認識させるには?
私は1つのプロトファイル、1つのPythonのファイルを持っているし、ファイルをビルドします。
$ find -type f
./WORKSPACE
./src/proto/BUILD
./src/proto/mymessage.proto
./src/python/foo/BUILD
./src/python/foo/foo.py
私のPythonスクリプトの輸入がいるProtobufのためのPythonのクラスを生成します。protoため
$ cat src/python/foo/foo.py
from src.proto import mymessage_pb2
message = mymessage_pb2.MyMessage()
message.my_field = "Hello world!"
print(message.my_field)
Pythonのクラスが生成されますこの方法:
$ cat src/proto/BUILD
package(default_visibility = ["//visibility:public"])
genrule(
name = "gen_mymessage_py_proto",
srcs = ["mymessage.proto"],
outs = ["mymessage_pb2.py"],
cmd = "protoc $(location mymessage.proto) --python_out=$(GENDIR) ",
)
py_library(
name = "mymessage_py_proto",
srcs = [":gen_mymessage_py_proto"],
)
Bazelはすべて期待通りに実行します:
$ bazel run src/python/foo:foo
INFO: Analysed target //src/python/foo:foo (16 packages loaded).
INFO: Found 1 target...
Target //src/python/foo:foo up-to-date:
bazel-bin/src/python/foo/foo
INFO: Elapsed time: 0.525s, Critical Path: 0.05s
INFO: Build completed successfully, 5 total actions
INFO: Running command line: bazel-bin/src/python/foo/foo
Hello world!
しかし、IntelliJのインポートを認識するために失敗します。
私はIntelliJのは、このインポートを認識させるために何ができますか?
bazel intellijプラグインのバグ修正:https://github.com/bazelbuild/intellij/issues/144 –