Hi! Does `resolve` respect filesystem hierarchy? e...
# general
a
Hi! Does
resolve
respect filesystem hierarchy? e.g. if I have something like this:
Copy code
BUILD(a)
...
foo/
   BUILD(b)
   ...
If I specify in
BUILD(a)
:
Copy code
python_sources(resolve="my-resolve")
but don’t specify a resolve in
BUILD(b)
, does it / can we make it follow what’s in
BUILD(a)
by default?
b
That isn't the case today because a target generator (like
python_sources
only applies to its generated targets, AND `pyhthon_sources`'s default field value for
sources
isn't recursive. So,
python_sources
has metadata only for this directory unless told otherwise. You could switch the
sources
field to be recursive (although there are drawbacks)
Copy code
python_soureces(
    # Not quite right, but you get the idea
    sources=["**/*.py"],
    ...
)
Or eagerly await
__defaults__
(here's the markdown documentation for this upcoming feature in 2.14) https://github.com/pantsbuild/pants/pull/15836/files#diff-f75e89f4936a42076eaf07a1a288169b36290b60b9095bb6a01cf22b95adf5e6
1
🙏 1
FWIW your request is not uncommon, the
__defaults__
feature is our first giant leap on the path to less metadata, and specifically leaning in to hierarchical metadata.
1
a
thanks @bitter-ability-32190 ! btw, can I make
./pants generate-lockfiles
ignore a requirements file?
b
🤷‍♂️ best ask in another thread
w
@ambitious-student-81104: if a requirements file doesn’t have a target associated, it will be ignored… failing that, you could put it in its own (unused…?) resolve
a
We can do that (put it in its own resolve) but it would be much easier if we can just tell pants to ignore it.
w
can you delete the target for the file?
and ask
tailor
not to recreate it?
a
hmm.. it’s used by some tests that we run with pants with
"--python-requirement-constraints"
So in this case, if we want to switch from our manual script to
./pants generate-lockfiles
we will still have to create multiple resolves?
w
if those tests actually need a different resolve (i.e., they have conflicting dependencies), then yes: it sounds like it. although you could probably continue to run pants twice (and use
constraints
in one of the runs) if you just marked the file as being in a separate resolve, but not the tests.
a
yeah they have actual conflicts
you could probably continue to run pants twice (and use
constraints
in one of the runs) if you just marked the file as being in a separate resolve, but not the tests.
but the tests will depend on the target of the
constraints
so they’d have to be in the save resolve, don’t they?
w
that would be recommended yea. but if you explicitly lied about your dependencies in the tests, and depended on the default resolve dependencies explicitly, then they could stay in the default resolve. they’d fail to actually test unless you set the constraints flag. not the cleanest solution.
a
oh yeah that actually worked. I have
./pants generate-lockfiles
with the default resolve successfully run, while the test code is also in the default resolve, but the requirements target is in a separate resolve
but if pants knows that the test code is a dependee of the
constraints
file requirements target, how can
./pants generate-lockfiles
succeed? doesn’t it figure that the test code depends on that constraints file? which is inconsistent with the fact that the constraints target is in a different resolve?
or does
./pants generate-lockfiles
only look at the requirements that are used in targets in this resolve?
w
or does
./pants generate-lockfiles
only look at the requirements that are used in targets in this resolve?
correct: all of the requirements targets which are labeled with a resolve are used in the lockfile, but no source targets matter
1
a
thanks a lot Stu, I have a much clearer understanding now