https://pantsbuild.org/ logo
c

cold-vr-15232

12/01/2022, 9:29 PM
I have several libraries in a monorepo. If I run "./pants package libs/lib1" it works ok, but if I run "./pants package ::" it breaks for some source file in lib1 (no python-distribution target found). Where should I look for answers to what is going on? I tried all combinations of parameters I could think of, maybe I messed the right one...
Oh, it looks like the file in question is not being packaged in the wheel, so I guess it's not used and then later pants wants to put it somewhere anyway? But for a library, unused modules should not be trimmed away, right? Clients can use whatever they want.
h

hundreds-father-404

12/01/2022, 9:48 PM
but if I run "./pants package ::"
It should be the case that each packaged thing is entirely independent. That is,
package ::
should be equivalent to first running
./pants --filter-target-type=pex_binary,python_distribution list ::
, then in a for loop running
./pants package $tgt
That should help you to isolate which targets are problematic. But also I think logs should say that?
c

cold-vr-15232

12/01/2022, 10:14 PM
Hmm, if the python_distribution target gets explicit dependencies to all the subpackages in the source directory, then it seems to work fine. So it is not enough to specify the top level package, because the modules that aren't used from inside there won't be included? Seems weird. It's ok for a pex binary, but for a library? Not the less because the internal structure of the package might change, and it doesn't feel like that should involve even updating the main BUILD file. I will check tomorrow in more detail.
h

happy-kitchen-89482

12/02/2022, 2:11 AM
If you have some module foo.bar.baz that you do want packaged into a distribution, then it must be reachable by transitive dependency from the explicit dependencies of the
python_distribution
target. So for example if there is a
main()
then typically the
python_distribution
only needs to depend on that, and it depends (via dep inference) on everything it needs.
But sometimes that may not bring in everything you intend to package, so you can add explicit deps as needed
But if the file isn’t reachable then I’m not sure why
./pants package ::
would ever be looking at it in the first place…
Can you post the full stack trace, with
-ldebug
?
c

cold-vr-15232

12/02/2022, 7:49 AM
The file is not reachable, so it's not a functional error in pants, in that sense. A library is not a binary with one entry point. It offers a multitude of utility modules and classes and functions. Clients use some or other, rarely all of them. Libraries are not a rare kind of deliverable. Given that one of Pants' best features is the minimal boilerplate, it feels weird to have to specify all the internal packages in the BUILD file. I think there should be a way to say "pick this package and everything beneath it". If there already is, then it should be more visible 🙂
4 Views