late-keyboard-89314
12/13/2022, 5:23 PMpython_distribution
that depends on some protobuf_sources
in a sibling directory. What do I need to specify in my dependencies field in order to satisfy the ownership constraint? Right now I have the following:
python_sources(name="lib")
python_distribution(
name="auth_service_client",
dependencies=[
":lib",
"src/proto/auth_service/service.proto:auth_service_interfaces",
],
provides=python_artifact(
name="auth_service_client",
version="0.0.1",
),
)
This is in the subdirectory that has my python sources for the library. It depends on some codegen protocol buffers in a sibling directory with the following BUILD file:
protobuf_sources(
name="auth_service_interfaces",
python_source_root="src/python",
grpc=True,
)
Pants is aware of the dependency between the python_source
generated by `python_sources`:
./pants dependencies src/python/auth_service_client/client.py
src/proto/auth_service/service.proto:auth_service_interfaces
src/python:reqs#grpcio
But when I try to package, I get the following error message:
NoOwnerError: No python_distribution target found to own src/proto/auth_service/service.proto:auth_service_interfaces. Note that the owner must be in or above the owned target's directory, and must depend on it (directly or indirectly). See <https://www.pantsbuild.org/v2.14/docs/python-distributions> for how python_sources targets are mapped to distributions. See <https://www.pantsbuild.org/v2.14/docs/python-distributions>.
I read through the docs but Iβm not understanding how to map the protobuf_sources
to a python_sources
target that my distribution can depend on. What am I missing here?enough-analyst-54434
12/13/2022, 5:39 PMenough-analyst-54434
12/13/2022, 5:40 PMpython_distribution
target to a BUILD file that satisfies that constraint.late-keyboard-89314
12/13/2022, 5:41 PM.
βββ pants
βββ pants.toml
βββ src
βββ go
β βββ BUILD
β βββ cmd
β β βββ auth-server
β β βββ BUILD
β β βββ main.go
β βββ go.mod
β βββ go.sum
β βββ pkg
βββ proto
β βββ auth_service
β βββ BUILD
β βββ service.proto
βββ python
βββ BUILD
βββ auth_service_client
β βββ BUILD
β βββ __init__.py
β βββ client.py
βββ auth_test_service
β βββ BUILD
β βββ __init__.py
β βββ main.py
βββ requirements.lock
βββ requirements.txt
The only way to package auth_service_client
is by creating a BUILD file in src
or the root of the repo?late-keyboard-89314
12/13/2022, 5:42 PMlate-keyboard-89314
12/13/2022, 5:47 PMpython_distribution
has to live outside the actual library code. Thank you!enough-analyst-54434
12/13/2022, 5:48 PMenough-analyst-54434
12/13/2022, 5:50 PMhappy-kitchen-89482
12/13/2022, 5:59 PMpython_distribution
to publish it in. There is a documented algorithm for how it selects that python_distribution
, and that algorithm relies on it being "above" the source file in the filesystem hierarchy.late-keyboard-89314
12/13/2022, 6:01 PMpython_distribution
into a new BUILD file in the parent src directory and then adjusting the path to :lib
worked exactly as expected.late-keyboard-89314
12/13/2022, 6:03 PMauth_service_client
project set, so I guess it ends up in a sibling directory there? Could I also have put this distribution in the BUILD file under python
?