acoustic-house-77496
09/19/2023, 7:43 PMpython_sources(
name="lib",
sources=["scripts/*.py"],
dependencies=[
f"{base_path}/package1:lib",
f"{base_path}/package2:lib",
f"{base_path}/package3:lib",
f"{base_path}/packageN:lib"
],
)
python_sources(
name="lib",
sources=["scripts/*.py"],
dependencies=[
f"{base_path}/package*:lib", #does not work
],
)
curved-television-6568
09/19/2023, 8:02 PMtarget
to avoid duplicating the effort of maintaining that list if you have it in multiple places..
target(
name="libs",
dependencies=[
f"{base_path}/package1:lib",
f"{base_path}/package2:lib",
f"{base_path}/package3:lib",
f"{base_path}/packageN:lib"
],
)
python_sources(.., dependencies=[":libs"])
another option is you can potentially reduce the boilerplate by using a function (or as a macro if you need the same thing in more than one BUILD file):
def libs(*names, base_path="src/path/..."):
for name in names:
yield f"{base_path}/{name}:lib"
python_sources(.., dependencies=[*libs("package1", "package2", ...)])
acoustic-house-77496
09/19/2023, 11:19 PMenough-analyst-54434
09/19/2023, 11:53 PMpants list the/build/file/is/in/here:
The :
is like *
, glob all targets here. The ::
is like **
, glob all targets here and under recursively.curved-television-6568
09/20/2023, 2:08 PMpants peek
acoustic-house-77496
09/21/2023, 7:50 AMdef search_dependencies(path:str)->list[str]:
# implementation
python_sources(
name="lib",
sources=["scripts/*.py"],
dependencies=search_dependencies(base_path)
)