Is there a way how Pants can be used to check for ...
# general
n
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
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
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
You have to be on 2.8.x for that
We probably want to enhance peek to add module/package names
👍 1
n
Ok, I will try with 2.8, thanks!