> The value of the dependencies field is a list...
# general
j
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
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
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
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
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
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
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
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
šŸŽ‰ šŸš€ šŸŽ‰
šŸ‘– 1