white-pager-32496
11/22/2022, 12:59 PMsources=["**/*.py"]
in a python_sources
target, so that all *.py
files in subdirectories are picked up.
I'm wondering if I'm doing something wrong 🙂 More context in 🧵white-pager-32496
11/22/2022, 1:01 PMtools
directory to house shared code among projects in the repo. It would look something like this:
src/tools
├── BUILD
├── __init__.py
└── log
├── __init__.py
└── logger_factory.py
With packages for logging, cryptography, etc. housed under src/tools
.white-pager-32496
11/22/2022, 1:02 PMsources
looking only in the directory housing the BUILD
file.white-pager-32496
11/22/2022, 1:02 PMwide-midnight-78598
11/22/2022, 1:09 PMtailor
(or in general), Pants defaults to 1 BUILD file per directory. So, there is no default recursive glob.
Personally, I use 1 BUILD file per "library" so I do something similar to what you're doingwide-midnight-78598
11/22/2022, 1:11 PMwide-midnight-78598
11/22/2022, 1:11 PMbitter-ability-32190
11/22/2022, 1:12 PMbitter-ability-32190
11/22/2022, 1:12 PMwide-midnight-78598
11/22/2022, 1:13 PMwhite-pager-32496
11/22/2022, 1:20 PMwhite-pager-32496
11/22/2022, 1:21 PMhappy-kitchen-89482
11/22/2022, 1:24 PMhappy-kitchen-89482
11/22/2022, 1:25 PMpython_rsources()
, say, that under the hood expands to python_sources(sources=["**/*.py"])
happy-kitchen-89482
11/22/2022, 1:25 PMwhite-pager-32496
11/22/2022, 1:26 PMhappy-kitchen-89482
11/22/2022, 1:27 PMhappy-kitchen-89482
11/22/2022, 1:28 PMhappy-kitchen-89482
11/22/2022, 1:30 PMwide-midnight-78598
11/22/2022, 1:32 PMhappy-kitchen-89482
11/22/2022, 1:32 PMsources=["**/*.py"]
might be too naive, as it will capture test-related code. The full default value is here: https://github.com/pantsbuild/pants/blob/24e5435cd7840d28520a6aa205375315c0dd8191/src/python/pants/backend/python/target_types.py#L1057happy-kitchen-89482
11/22/2022, 1:33 PMcold-vr-15232
11/22/2022, 1:53 PMhappy-kitchen-89482
11/22/2022, 1:56 PMpython_rsources()
)curved-television-6568
11/22/2022, 1:58 PMYou can wrap that up in a macro btw
So you can have a customThere’s also, say, that under the hood expands topython_rsources()
python_sources(sources=["**/*.py"])
__defaults__
if you prefer to keep using the standard target names (disregard if it’s becoming too much information at once):
__defaults__({python_sources: {"sources": ["**/*.py"]}})
https://www.pantsbuild.org/docs/targets#field-default-valueswide-midnight-78598
11/22/2022, 1:59 PMpython_sources
would then lead to something like that per backend, which feels like it would really bloat the number of targets, for a small number of BUILD files
and I say this as a recursive targets kinda personcurved-television-6568
11/22/2022, 3:01 PM