https://pantsbuild.org/ logo
#general
Title
# general
n

narrow-activity-17405

11/08/2021, 8:01 AM
Is there a way how Pants can be used to check for circular dependencies between packages? For instance, during the last release of our repo (containing multiple interdependent Python packages) I accidentally introduced mutual dependency between two packages (not between modules) and I would like to add some kind of check to prevent this to the CI. Any idea? :-)
h

happy-kitchen-89482

11/08/2021, 8:50 AM
Hi, you could use
./pants peek ::
to get a lot of JSON info about your targets, including their explicit and inferred dependencies, and then process that JSON outside Pants. Or if you want to check to be a Pants goal you can write a custom goal that consumes the same data structure used to produce that JSON (see here ) .
n

narrow-activity-17405

11/08/2021, 10:23 AM
Thanks for the tip. I tried
peek
but the resulting JSON does not seem to contain inferred dependencies if I'm looking right (I'm on Pants 2.7.0) - there is only stuff from BUILD files. I was also thinking about calling
./pants dependencies
on all top-level python libraries (where each has associated python distribution) and analyzing results, but that would require extracting package names from targets somehow, which would be quite specific and non-elegant 🙂 Maybe I can generate python distributions and read dependencies from their
setup.py
...
h

happy-kitchen-89482

11/08/2021, 1:13 PM
You have to be on 2.8.x for that
We probably want to enhance peek to add module/package names
👍 1
n

narrow-activity-17405

11/09/2021, 7:53 AM
Ok, I will try with 2.8, thanks!
3 Views