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

fresh-architect-74417

02/22/2021, 9:35 PM
Hi all: What happens to the dependencies section in pants v2?
w

witty-crayon-22786

02/22/2021, 9:44 PM
hey Ahmed! can you expand on what you mean? you can still add dependencies lists in BUILD files
e

enough-analyst-54434

02/22/2021, 9:44 PM
It hasn't changed except that you need to manually enter things there less often. See an intro over here and let us know if you have more questions: https://www.pantsbuild.org/docs/targets#dependencies-and-dependency-inference
f

fresh-architect-74417

02/22/2021, 9:47 PM
@witty-crayon-22786 Yeah, I looked at the examples and I found they are not there for pex_binary types. I use the dependencies for other internal tools such as sharding and continuous deployment.
w

witty-crayon-22786

02/22/2021, 9:48 PM
you can run the
./pants dependencies
goal to dump out the inferred dependencies
f

fresh-architect-74417

02/22/2021, 9:48 PM
The sharding in v1 had some issues for multiple targets, so we developed our own sharding for running the tests in the CI server.
@witty-crayon-22786 but it's still backward compatable with pants v1, right?
w

witty-crayon-22786

02/22/2021, 9:49 PM
./pants dependencies
? yes, it is
f

fresh-architect-74417

02/22/2021, 9:49 PM
No, not that command. Adding dependencies to the targets.
w

witty-crayon-22786

02/22/2021, 9:50 PM
you can manually add all of the dependencies to targets if you’d like to… dependency inference (see John’s link) is on by default: if you’d like to only support manually added dependencies, you can turn it off.
but we would recommend using inference. see https://blog.pantsbuild.org/dependency-inference/ for more info beyond what is on the docsite.
f

fresh-architect-74417

02/22/2021, 9:54 PM
I have in my code for example an import for dev_constants that I don't include in the final product pex file. That's why I asked. Plus, we use build files to decide what needs to be deployed, or what tests need to run.
How do I turn it off in pants v2?
If I include it in the BUILD file, does it get turned off?
w

witty-crayon-22786

02/22/2021, 9:55 PM
it can be turned off globally using https://www.pantsbuild.org/docs/reference-python-infer
adding dependencies in BUILD files doesn’t turn off inference (because as you mentioned, not all dependencies can be inferred).
but we would recommend against parsing BUILD files in your code, and would suggest using
./pants dependencies
to do that instead. that’s backwards compatible, and supports both inference and manual dependencies.
also, it’s worth noting that Pants v2 will run tests in parallel, so some smaller uses of sharding might not be necessary.
f

fresh-architect-74417

02/22/2021, 10:01 PM
Yeah, but that won't work for me. I read the BUILD files from Python via a custom parser I wrote. If I run
./pants dependencies
, it means I will need to run it via os.system, or a subprocess. That is extramurally slow. It means we will need to run that command on every modified target. We had that originally implemented in first version of our continuous deployment script, and I replaced it with a custom parser. We had almost 100x improvement after I did that.
For the sharding, it won't work. Some of the tests interfere with each others, we run the tests in containers. Where each container runs a shard number.
w

witty-crayon-22786

02/22/2021, 10:02 PM
regarding running
./pants dependencies
once per target: that’s not what we would recommend: see https://www.pantsbuild.org/docs/using-pants-in-ci#recommended-commands instead
try running
./pants --changed-since=origin/main --changed-dependees=transitive list
in a branch, and see how long it takes
f

fresh-architect-74417

02/22/2021, 10:03 PM
😄
Our branching system is kinda ackward
It's like this
mw-4.1.0, mw-4.1.1 and so on
We don't have a single main or master.
w

witty-crayon-22786

02/22/2021, 10:03 PM
sure… you can pass in whatever merge-base you would like. the
--changed-since
flag takes a git-ref as an argument.
f

fresh-architect-74417

02/22/2021, 10:04 PM
I will give it a try
Thank you ^_^
w

witty-crayon-22786

02/22/2021, 10:04 PM
sure thing!
5 Views