I am attempting to get my head around a dependency...
# general
f
I am attempting to get my head around a dependency scenario, with the python_artifact() scenario 1.
vcs_version(..)
creates
somefolder/VERSION
(
name = "version_txt_file"
) 2. the
python_distribution
depends upon that target
Copy code
python_distribution(
    name = "jlab",
    dependencies = [
        ":pyproject",
        ":version_txt_file",
        "//:my_sources",
        "//:reqs#setuptools",
        "//:reqs#wheel",
    ],
    generate_setup = True,
    provides = python_artifact(
        name = "mylib",
    ),
    ...
)
3. have a custom plugin, which registers the custom setup_kwargs for the python distribution. the germain point is, it looks for the file, created in 1. (and changelog - but thats the same scenario - a target
shell_command(..)
produces it)
Copy code
@rule
async def setup_kwargs_plugin(request: CustomSetupKwargsRequest) -> SetupKwargs:
    async def get_version() -> str:
        """returns the VERSION file contents"""
        digest_contents = await Get(
            DigestContents,
            PathGlobs(
                [f"{request.target.get(PythonProvidesField).value}/VERSION"], # this needs to be more robust later
                description_of_origin=f"{__name__}: get_version(), from `python_artifact()` plugin",
                glob_match_error_behavior=GlobMatchErrorBehavior.error,
            ),
        )
        version = digest_contents[0].content.decode().strip()
        return version

    async def get_changelog() -> str:
        ...

    version = await get_version()
    changelog = await get_changelog()

    return SetupKwargs(
        {**request.explicit_kwargs,
         "version": version,
         "long_description": changelog,
         },
        address=request.target.address
    )
so how to I "add" the target
vcs_version(..) somefolder/VERSION   (name = "version_txt_file" )
as a dependency to the macro call,
python_artifact(...)
I can see that the
PythonArtifact
class - the type, on the
provides =
is designed as a macro. https://github.com/pantsbuild/pants/blob/a629197819456478078a35c788d2e1ead73d01ba/src/python/pants/backend/python/register.py#L62 The challenge i think is, the python_artifact does not have a 'depdencies' field that I can attach the
:version_txt_file
target to
h
IIRC you want the
vcs_version
target to be the dep of some
python_source
that imports or otherwise loads its output?