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

jolly-midnight-72759

05/24/2020, 3:23 PM
The value of the dependencies field is a list of addresses of other targets. If code in target A directly depends on code in target B (e.g., by importing a symbol from B) then A should declare a dependency on B. There is no need to declare indirect dependencies (that is, transitive dependencies of your direct dependencies).
I think it would be helpful to mention that there are two types of dependencies: 3rdparty and other monorepo target.
👍 1
3rdparty dependencies and their transitive dependencies must be available through defined repositories.
h

hundreds-father-404

05/24/2020, 3:51 PM
Good idea! Related, we’re working on a project to add “dependency inference”. For python, Pants will be able to read your source code import statements to automatically populate
dependencies
. You can explicitly add any others you’d like
j

jolly-midnight-72759

05/24/2020, 3:54 PM
If that is successful, then the only dependencies that would need to be declared are for non-code files (eg
*.yaml
etc).
Although, I would imagine pants would follow the same learning lessons of
setup.py
.
h

hundreds-father-404

05/24/2020, 3:55 PM
Precisely! Or if you for some reason used importlib.import, for example. Our goal is to reduce the maintenance burden of BUILD files, which we think is one of the sore spots of build tools like Pants and Bazel.
👍 1
Although, I would imagine pants would follow the same learning lessons of
setup.py
.
What do you mean?
j

jolly-midnight-72759

05/25/2020, 1:48 AM
There are a number of parallels in
setup.py
(from setuptools) to the pant's
BUILD
files. Both define the following metadata: •
name
packages
or
source
code •
package_data
or
resources
install_requires
or
dependencies
(what you are proposing to automate) •
python_requires
or
compatibility
Things setuptools has that pants does not: •
description
version
packages
• etc And because these are not useful to
pex
, pants doesn't need these.
So I don't know the history of setuptools, but I imagine that knowing that might be helpful to making design decisions for pants's
BUILD
files. (Then again maybe not.) They are serving different purposes, but there are a lot of parallel evolution going on.
Two things that setuptools has is a
scripts
option, which I don't think is useful to pants because of the power of 111.
And
find_packages
, which isn't needed because,
source
can be filled by using the 111 pattern and file names conventions.
Maybe the most flexible way for pants to handle the
dependencies
field is to imitate the
find_packages
but with a
find_dependencies
method. This method could be the default for when
dependencies
is missing from the
BUILD
file, or it can be added from the list of
dependencies
for when a project wants to explicitly declare some dependencies. When a project wants no automatic discovery, then
find_dependencies
can be excluded.
Sorry. I should of written a blog. 😄
h

hundreds-father-404

05/27/2020, 3:14 PM
Interesting, I’ve never thought of comparing a
setup.py
to a BUILD file. At a high level, it’s a fair comparison. They both exist for metadata about some of your code.
field is to imitate the find_packages but with a find_dependencies method
Are you envisioning the user explicitly typing
find_dependencies
? Instead, the plan is that Pants will automatically do it no matter what (if you have the backend registered). If you explicitly specified everything, Pants will have nothing to add. If you explicitly specified 3/5 imports, then Pants will fill in the rest, etc
Thank you also for taking the time to write that out ❤️
j

jolly-midnight-72759

05/27/2020, 3:59 PM
setup.py
requires people to type it explicitly. After thinking about it, it doesn't make sense for
BUILD
to require that. BUT it would be good to be able to turn the automatic find dependency off Just in Case™.
👍 1
h

hundreds-father-404

05/27/2020, 4:01 PM
Agreed with being able to disable it. It’s especially helpful for debugging for users to be able to try a run with and without it Btw, the way you’ll see what Pants resolves is using the dependencies goal:
./pants dependencies project/app.py
j

jolly-midnight-72759

05/27/2020, 4:03 PM
🎉 🚀 🎉
👖 1
4 Views