Hi, Can i reference a target from build BUILD file...
# general
h
Hi, Can i reference a target from build BUILD file in another if those 2 BUILD files are in adjacent folders? My specific issue is that I have a (Python) package which has implicit dependencies on
.py
files in another package. I thought to solve this by adding the following target in the first BUILD file:
Copy code
"dependencies": [
        ":second-package-sources",  # this refers to all of the '.py' files in the second package
    ],
1
e
":x" is a shortcut for targets defined in BUILD files in the same directory. For all others, use the full path from the build root, i.e.: "src/python/other/package/dir:second-packages-sources".
h
Ooh!
e
The full form is spelled out here: https://www.pantsbuild.org/docs/targets#target-addresses The abbreviated ":x" form is somewhat weirdly only called out later after switching to talking about sources and dependencies fields.
h
I see. Well, that solved it. Do you maybe know if there is a better solution for cases in which a package is a bundle of
py
files that are dynamically imported based an application conditions?
e
Nope, that's the most straightforward way. Everything else will probably be more complication than its worth.
What's the loading mechanism? Conditional static imports or dynamic string imports?
h
dynamic string imports
e
h
The strings are an input that are constructed dynamically too DX
c
depending on your use case, there’s support for stevedore plugins in pants most recent versions: https://github.com/pantsbuild/pants/pull/18132 may or may not be suitable for you..
h
Will take a look, thanks 🙂