我遇到了Bazel无法解决python目标的上级依赖的问题。看起来就是这样。
我有一个名为//path/to/target1/target1-child:target1_object
的目标,它依赖于//path/to/target2:target2_objective
//path/to/target1/target1-child:target1_object
在path/to/target1/target1-child/BUILD
文件中定义为:
py_library(
name = "target1_object",
srcs = ["target1_object.py"],
deps = [
...
"//path/to/target2:target2_objective",
requirement("..."),
],
)
和//path/to/target2:target2_objective
在path/to/BUILD
文件中定义为:
py_library(
name = "target2",
srcs = ["target2.py"],
deps = [
requirement("django"),
],
)
但是bazel build
返回:
ERROR: Analysis of target '//path/to/target1/target1-child:target1_object'
failed; build aborted: no such package 'path/to/target2': BUILD file not
found on package path
但是目标已经正确定义。
使target2
可以使用target1-child
的正确方法是什么?