clean-window-81064
02/06/2023, 9:30 AMpython_distribution
in the root I am observing AmbiguousOwnerError
exception.
I am quite certain that pants can package multiple distributions from the same repo, so maybe I am approaching this wrong ?
The 2 distributions namely rl
and data_processing
share some common library code such as quitter, protos, dao etc and the expectation here is that they get packaged in both the distributions (i.e without a single distribution being the sole owner).
I think in my case I essentially want the same code to be published in multiple distributions (the 2 distributions are isolated from each other and won’t ever run together so the associated risk is mitigated)
Error snippet -
AmbiguousOwnerError: Found multiple sibling python_distribution targets that are the closest ancestor dependees of src/backend/abc/libs/service/quitter.py:quitter and are therefore candidates to own it: src/backend/abc:rl, src/backend/abc:data_processing. Only a single such owner is allowed, to avoid ambiguity. 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 couldn’t find a lot of information on pants docs related to AmbiguousOwnerError
& was wondering if this is a loose requirement and maybe there is a flag to tweak it such that >=2 distributions can live together in the root ? or is there any other standard process for packaging multiple distributions. Another way I could think of is - Package the common code as separate distribution (say common_libs
) and mark it as dependency in the final distributions i.e rl
and data_processing
or manual setup.py (which I am trying to avoid)
PS: Fwiw, our near-future plan is to leverage the pants python_distribution
target for packaging multiple packages.refined-addition-53644
02/06/2023, 10:44 AMNaively, you might think that apublishes all the code of all thepython_distribution
targets it transitively depends on. But that could easily lead to trouble if you have multiple distributions that share common dependencies. You typically don’t want the same code published in multiple distributions, as this can lead to all sorts of runtime import issues.python_source
If you use a handwritten, you have to figure this out for yourself - Pants will bundle whatever the script tells it to.setup.py
refined-addition-53644
02/06/2023, 10:45 AMclean-window-81064
02/06/2023, 10:58 AMrefined-addition-53644
02/06/2023, 11:03 AMThe generatedwill have itssetup.py
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.install_requires
cold-vr-15232
02/06/2023, 11:58 AMclean-window-81064
02/06/2023, 12:14 PMcold-vr-15232
02/06/2023, 2:35 PMclean-window-81064
02/07/2023, 10:15 AMpython_distribution
it’s throwing ambiguity error since the common libs are to be shared in both the distributions and pants doesn’t allow multiple owners for same python_source.
So I am stuck now 😕cold-vr-15232
02/07/2023, 1:03 PM