Hi All, I'm using `experimental_wrap_as_python_sou...
# general
m
Hi All, I'm using
experimental_wrap_as_python_sources
to create python sources from an
openapi
generated code, I have an issue with adding dependencies to the generated
python_source
The generated code uses
pydantic
so I want pydantic to be a dependency for any source that uses the generated client. My BUILD file looks like this:
Copy code
shell_command(
    name="build_client",
    command="docker run --rm -v $PWD:/local openapitools/openapi-generator-cli generate " \
        "-i /local/research/deployment/openapi.yaml -g python-pydantic-v1 -o /local/ " \
        "--package-name model_client --additional-properties='generateSourceCodeOnly=True'",
    execution_dependencies=[":openapi_schema"],
    tools=["docker"],
    output_directories=["model_client"],
    workdir="/",
    timeout=600,
    output_dependencies=["//:reqs#pydantic"]
)

experimental_wrap_as_python_sources(
    name="model_client",
    inputs=[":build_client"]
)

python_source(
    name="example",
    source="./bla.py",
    dependencies=[":model_client"]
)
running the
example
target fails with this error:
ModuleNotFoundError: No module named 'pydantic'
. Is there any way to add dependencies to the
experimental_wrap_as_python_sources
target?
l
This looks related to https://github.com/pantsbuild/pants/issues/19687 but that is about resources which should be different ...
For now are you able to get by adding the dependency to the consumer of
:model_client
?
Copy code
python_source(
    name="example",
    source="./bla.py",
    dependencies=[":model_client", "//:reqs#pydantic"]
)
not very satisfying but seems like should get you through until we can find a solution to attach dependencies to shell-generated sources. Could not find it looking in the slack or issue history yet.
👍 1
m
thanks for the answer. I can do this in the meantime, was wondering if I can avoid stating the dependencies on every consumer