https://pantsbuild.org/ logo
a

ambitious-student-81104

07/11/2022, 4:34 PM
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

bitter-ability-32190

07/11/2022, 4:38 PM
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

ambitious-student-81104

07/11/2022, 4:43 PM
thanks @bitter-ability-32190 ! btw, can I make
./pants generate-lockfiles
ignore a requirements file?
b

bitter-ability-32190

07/11/2022, 4:44 PM
🤷‍♂️ best ask in another thread
w

witty-crayon-22786

07/11/2022, 4:52 PM
@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

ambitious-student-81104

07/11/2022, 4:53 PM
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

witty-crayon-22786

07/11/2022, 4:54 PM
can you delete the target for the file?
and ask
tailor
not to recreate it?
a

ambitious-student-81104

07/11/2022, 5:02 PM
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

witty-crayon-22786

07/11/2022, 5:04 PM
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

ambitious-student-81104

07/11/2022, 5:05 PM
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

witty-crayon-22786

07/11/2022, 5:08 PM
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

ambitious-student-81104

07/11/2022, 5:09 PM
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

witty-crayon-22786

07/11/2022, 5:12 PM
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

ambitious-student-81104

07/11/2022, 5:18 PM
thanks a lot Stu, I have a much clearer understanding now
4 Views