I’m writing a Pants plugin to infer some dependenc...
# general
c
I’m writing a Pants plugin to infer some dependencies. In each directory, I have a
BUILD
file like follows in every directory.
Copy code
python_sources(
    name="package_config",
    sources=[
        "_package_config.py",
    ],
)

python_sources()
Each directory containing a
BUILD
file with the
package_config
target name contains a corresponding
_package_config.py
file. My dependency inference rule (simplified) does something along the lines of this.
Copy code
@rule(desc="...")
async def infer_dependencies(
    request: InferPackageConfigDependenciesRequest
) -> InferredDependencies:
    return InferredDependencies([Address("path/to/directory:package_config")])
I’m getting the following error when running
./pants dependees …
Copy code
ResolveError: Directory 'path/to/directory:package_config' does not contain any BUILD files.
Is there a way to write my plugin such that it knows that I’m referring to a
python_sources
target, and not a directory?
c
the message seem to suggest there is no
path/to/directory/BUILD
file, so, where is your python_sources target defined?
c
I think I’m using the API incorrectly or it’s just confused. I’m providing
path/to/directory:package_config
to the
Address
constructor, and
path/to/directory:package_config
is a target defined in
path/to/directory/BUILD
c
ah, yes.. this
Address("path/to/directory:package_config")
should be
Address("path/to/directory", target_name="package_config")
c
Amazing!! Let me try that