<https://www.pantsbuild.org/docs/python-distributi...
# general
h
https://www.pantsbuild.org/docs/python-distributions
The generated
setup.py
will have its
install_requires
set to include the 3rdparty dependencies of the code bundled in the distribution, plus any other distributions from your own repo. For example, if distribution D1 contains code that has a dependency on some source file S, and that source file is published in distribution D2, then D1's requirements will include a dependency on D2. In other words, Pants does the right thing.
How should this D2 dependency be written? Should we be able to include it as a Pants target like so? Can’t seem to resolve the AmbiguousOwnerError
Copy code
python_distribution(
    name="D2",
    dependencies=["dirs/dir-D2"],
)

python_distribution(
    name="D1",
    dependencies=[
        "dirs/other-dir",
        ":D2"
    ],
)
c
you shouldn’t need to declare your in-repo dependencies. Those will be inferred based on the imports in your code.
And yea, you can’t have multiple
python_distribution
targets in the same BUILD file for the same set of sources, which you get in the above example. Pants won’t be able to tell which dist should own the sources based on the rule that the dist target closest to the source wins.
h
Okay that makes sense, are there any plans to add to that rule to support this case? I don’t think it’s unreasonable to define distributions with overlapping dependencies in the same place, so maybe the rule could be based on if a valid dependency tree could be resolved for the connect distributions.
c
I guess that the number of targets you traverse could be added to the distance used to calculate closeness.. in which case it would resolve your case above at least.
h
> you shouldn’t need to declare your in-repo dependencies. Those will be inferred based on the imports in your code. Another question on this, is there a way to explicitly set these in-repo dependencies (for python_distribution) out of interest? Rather than rely on Pants’ inference
c