https://pantsbuild.org/ logo
#general
Title
# general
h

hundreds-father-404

08/19/2020, 10:20 PM
Another approach is to have two targets referring to the same util code. One with tensorflow, and one without:
Copy code
python_library(
  name="utils_without_tf",
  dependencies=["foo", "bar"]
)

python_library(
  name="utils",
  dependencies=[":utils_without_tf", "//:tensorflow"]
)
But this means that the BUILD file authors must now go out of their way to depend on the correct target. And generally Pants is less ergonomic when there’s >1 target owning a file. For example, dependency inference wouldn’t be able to infer a dependency anymore because it doesn’t know which of the two targets you want to use.