proud-dentist-22844
05/31/2021, 3:44 PMA
with subdirectories B
, C
, D
(and many others), I want to create a target()
that encompasses the :metadata
targets in all subdirectories (so ./B:metadata
, ./C:metadata
, ./D:metadata
and every other subdirectory). Can I use globs to create dependencies?
I've tried several glob variations, none of which seem to do what I'm looking for: **:metadata
./**:metadata
*:metadata
./*:metadata
...proud-dentist-22844
05/31/2021, 3:56 PM./dummy*:metadata
and got this error:
DifferingFamiliesError: Expected AddressMaps to share the same parent directory 'st2tests/st2tests/fixtures/packs/dummy*', but received: 'st2tests/st2tests/fixtures/packs/dummy_pack_1/BUILD'
proud-dentist-22844
05/31/2021, 4:01 PMhundreds-father-404
05/31/2021, 4:04 PMtarget
target https://www.pantsbuild.org/docs/reference-targetproud-dentist-22844
05/31/2021, 4:19 PMtarget()
, but do I really have to register every subdirectory individually in the BUILD file?proud-dentist-22844
05/31/2021, 4:20 PMenough-analyst-54434
05/31/2021, 4:33 PMenough-analyst-54434
05/31/2021, 4:36 PMenough-analyst-54434
05/31/2021, 4:39 PMproud-dentist-22844
05/31/2021, 4:57 PM:metadata
targets get added by a tailor
rule I wrote. The tests that use the fixtures in this directory expect to have access to all of the fixtures (they are all similar w/ slight variations for the various tests). When someone adds a new subdirectory, ./pants tailor
can easily take care of adding the new BUILD file, but I don't want people to forget to register it in the parent directory's super target.enough-analyst-54434
05/31/2021, 5:09 PMproud-dentist-22844
05/31/2021, 5:33 PMst2tests
whose sole purpose is to provide files fixtures for tests in other modules.
I don't have a good way to say "this test file needs these fixture files", so I made top-level python_library
target in st2tests
depend on most of the files
targets within that module so that if you impor st2tests.fixtureloader
, pants knows to include all the files as well.
There are quite a few fixtures in there, so I'm trying to figure out how to set up the targets for the various fixtures so that they get picked up. I can't just do sources=['**/*']
because there are python targets in there as well.proud-dentist-22844
05/31/2021, 5:34 PMenough-analyst-54434
05/31/2021, 5:47 PMsources=['**/<fixture file naming pattern>']
proud-dentist-22844
05/31/2021, 5:53 PMproud-dentist-22844
05/31/2021, 6:01 PMenough-analyst-54434
05/31/2021, 6:01 PMproud-dentist-22844
05/31/2021, 6:13 PMproud-dentist-22844
05/31/2021, 6:14 PMproud-dentist-22844
05/31/2021, 6:14 PMproud-dentist-22844
05/31/2021, 6:15 PMenough-analyst-54434
05/31/2021, 6:18 PMproud-dentist-22844
05/31/2021, 6:18 PMproud-dentist-22844
05/31/2021, 6:19 PMenough-analyst-54434
05/31/2021, 6:21 PMproud-dentist-22844
05/31/2021, 6:21 PMenough-analyst-54434
05/31/2021, 6:22 PMproud-dentist-22844
05/31/2021, 6:24 PMenough-analyst-54434
05/31/2021, 6:26 PMenough-analyst-54434
05/31/2021, 6:27 PMenough-analyst-54434
05/31/2021, 6:28 PMenough-analyst-54434
05/31/2021, 6:28 PMenough-analyst-54434
05/31/2021, 6:30 PMproud-dentist-22844
05/31/2021, 6:30 PMenough-analyst-54434
05/31/2021, 6:31 PMproud-dentist-22844
05/31/2021, 6:31 PMenough-analyst-54434
05/31/2021, 6:32 PMproud-dentist-22844
05/31/2021, 6:34 PMenough-analyst-54434
05/31/2021, 6:34 PMproud-dentist-22844
05/31/2021, 7:14 PMst2tests/st2tests/fixtures/packs/dummy_pack_1/fixture.py
then I can import the vars I need from there, however, pants isn't inferring that dependency according to ./pants dependencies st2common/tests/unit/test_aliasesregistrar.py
Would overlapping source roots make it difficult for pants to infer dependencies?
pack.yaml
is a source root marker file, and there is a st2tests/st2tests/fixtures/packs/dummy_pack_1/pack.yaml
file, so could that be messing this up?proud-dentist-22844
05/31/2021, 7:18 PMproud-dentist-22844
05/31/2021, 7:18 PMproud-dentist-22844
05/31/2021, 7:18 PMenough-analyst-54434
05/31/2021, 7:25 PMenough-analyst-54434
05/31/2021, 7:26 PMenough-analyst-54434
05/31/2021, 7:28 PMenough-analyst-54434
05/31/2021, 7:28 PMproud-dentist-22844
05/31/2021, 7:49 PMproud-dentist-22844
05/31/2021, 10:37 PMproud-dentist-22844
05/31/2021, 10:37 PMenough-analyst-54434
05/31/2021, 10:50 PMos
import, the __all__
and reduce the symbols to something like NAME, PATH = fixtures loader.here()
by using something like https://github.com/pantsbuild/pants/blob/24991b67600e17cbbf2d16591f5c3eb47fe0388e/src/python/pants/engine/rules.py#L352-L363proud-dentist-22844
06/01/2021, 12:49 AM__file__
as an arg.proud-dentist-22844
06/01/2021, 2:01 AMhappy-kitchen-89482
06/01/2021, 9:54 AM