https://pantsbuild.org/ logo
#general
Title
# general
p

proud-dentist-22844

06/03/2021, 3:02 AM
I could use some ideas on how to deal with this symlink: https://github.com/st2sandbox/st2/blob/pants/st2tests/st2tests/fixtures/packs/core which links to: https://github.com/st2sandbox/st2/tree/pants/contrib/core I'm going to talk about the two distribution paths, to help with understanding why other people added the symlink, but I'm not asking about distribution/archives/etc.
contrib/core
primarily has files+code (in a StackStorm pack) that gets installed with StackStorm itself. But, it is also distributed as part of the
st2tests
module which provides general purpose test fixtures for use in the StackStorm ecosystem. There are a couple of issues with the symlink. The first of which was disambiguating a dependency which was simple enough: https://github.com/st2sandbox/st2/blob/pants/contrib/core/tests/BUILD#L3 The next couple of issues are intertwined: • For all the other fixtures, I used a python import so that pants could infer the dependency from test to fixture. But that get's a little odd with the symlinked code living in two places. •
contrib/core
is a source root (identified by a
[source].marker_filenames
file), but
st2tests/fixtures/packs/core
should not be a source root. Please help me think through what to do about this. I'm not even sure what questions to ask. Any thoughts?
h

happy-kitchen-89482

06/03/2021, 2:37 PM
Hmmm
Need to ponder this
👍 1
How many source roots do you have, total? Wondering if you could enumerate them in the source root config, instead of using marker files
1
p

proud-dentist-22844

06/03/2021, 11:33 PM
I had a regex, but a core contributor for ST2 didn’t like that. Then I used
pack.yaml
as a marker file, which conflicted with how I had to load the fixtures. Now I’ve got a more limited set of files with an empty
PACK_ROOT
file. There are 7 (maybe 9) of those, so I guess I’ll just have to list them.
That’s 7 in addition to another 9 patterns already in my pants.toml file
h

happy-kitchen-89482

06/04/2021, 6:22 AM
Not sure this will help though - there is always a source root. Pants takes the innermost dir that looks like one based on the source_roots config. So if all else fails it'll treat the repo root like a source root for
st2tests/fixtures/packs/core
Which is presumably not what you want
Well, although, the import problem will be solved since the import path won't be the same relative to the source root
So actually this probably will help
p

proud-dentist-22844

06/04/2021, 4:45 PM
Hmm. OK I think that resolves it. Thanks. Here's my big long explanation of why for future people that want to simplify: https://github.com/st2sandbox/st2/blob/pants/pants.toml#L40-L71
h

happy-kitchen-89482

06/05/2021, 9:43 AM
Thanks for the explanation!