https://pantsbuild.org/ logo
h

high-yak-85899

03/01/2023, 10:21 PM
Where's the latest and greatest on how dependency inference works for files/resources targets? I'd like to try it out, but I don't remember where in the docs/blogs specifies how to use it.
l

loud-laptop-17949

03/01/2023, 10:22 PM
h

high-yak-85899

03/01/2023, 10:23 PM
That doesn't seem to mention automatic inference, though.
l

loud-laptop-17949

03/01/2023, 10:24 PM
hmm you are right
e
h

high-yak-85899

03/01/2023, 10:30 PM
Thanks! Any examples of what the strings look like? Do you have to hardcode something relative to the project source root to be inferred?
e

enough-analyst-54434

03/01/2023, 10:40 PM
The strings are whatever works with
__import("...")__
or
importlib.importmodule("...")
.
So the string must be a valid Python module that can be found on the
sys.path
at runtime.
Perhaps I'm not understanding the question.
h

high-yak-85899

03/01/2023, 10:41 PM
Oh, I thought it was for picking up generic files
Like say I have a yaml resource
e

enough-analyst-54434

03/01/2023, 10:42 PM
Oh, right:
Copy code
Infer a target's asset dependencies based on strings that look like Posix filepaths, such as those given to open or pkgutil.get_data.
That seems pretty clear to me.
Experiment!
c

careful-address-89803

03/02/2023, 4:13 AM
If you're after 2.16.0.dev1 You can try the
python-dump-source-analysis
goal, it'll tell you what Pants is thinking. It's possible that Pants has found something that looks like it could be an inferred file, but it can't find the file (for whatever reason) and isn't going to sweat it. I think the most relevant source is here , which talks about the specifics of which files Pants looks for when it finds a possible asset import
4 Views