What's the best way to automatically depend on all...
# general
What's the best way to automatically depend on all
below a certain BUILD file? I noticed that tailor isn't automatically creating a BUILD definition in the root of a package anymore?
I'll focus on the 1st sentence first. I think there is no way to do this automatically (via tailor), especially since we generally encourage 111 (See the tip at the bottom of the page here: https://www.pantsbuild.org/docs/targets). To do it manually you use
python_sources(..., sources=["**/*.py"])
, but I'm guessing you knew that.
Yeah, that's what I ended up doing but Pants threw a lot of warnings my way. The use case being that I want to create a package of everything below a certain path without having to manually maintain the list of named dependencies to correspond with each root node BUILD file. Good enough for now though 🙂
Well, you shouldn't have to do the latter. Modern Pants auto-infers dependencies. What version of Pants is this?
FWIW this request comes up pretty regularly. @hundreds-father-404 has a proposal which may make this feasible
Do you have a pointer @bitter-ability-32190? From the words here I still don't understand what it is Pants can't do that is well known.
Afaict pants (
) doesn't auto-generate recursive globs, but that's by choice / design / 111 promotion and not because of any technical limitation.
I tried looking last time this came up from the google doc but can't find it 😓 Basically, "bending" 111 to allow subdir-globbed ownership while also allowing lower-lever
files to act as an "override" for the root one.
Ah, yeah. That was proposed by Benjy a long time ago, hierarchical configuration, closest config wins. That is only detailed in tickets and design docs as far as I know. I don't think that's the issue @limited-insurance-37393 has.
Although it would solve his issue.
So, the specific BUILD file in question is visible here: https://github.com/mitodl/ol-infrastructure/blob/main/src/ol_infrastructure/BUILD
As a naive assumption what would be nice is to have a BUILD file located at the root of a Python package and that it will automatically discover and include all of the sources in the descendant directories/modules within that package, rather than having to recusively glob for Python files contained below that BUILD.
That way I can defer to the specific BUILD configurations in the descendant paths to know when they need to rely on different resources/files or exclude certain assets from the built package, etc.
For now what I have works well enough, but was curious about whether there was a more native/supported way of doing things.
Aha, OK so you do want hierarchical configuration. Yeah. An old idea circa 2019 that we have just never got around to. I think Eric will be pushing this now though, time permitting, this year.
So @bitter-ability-32190 was on point.
🙌 1
If I ever unclog my own personal Pants backlog, I'd be willing to pair this with Eric 😄
🙌 3