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

future-oxygen-10553

02/14/2023, 7:24 PM
Hi all, I’m trying to sort out some dependency management between first party code. I have a sample repo here: https://github.com/bryanwweber/pants-multi-deps The short version is I have a module
ops_core.data_io.pathlib
from which a function is imported, and a client
client_code.client
that uses the import. However,
pants
warns me that the dependency can’t be inferred. Any help is appreciated!
Copy code
❯ pants --no-pantsd dependencies --transitive src/client_code/client_code/client.py
14:21:31.74 [WARN] Pants cannot infer owners for the following imports in the target src/client_co
de/client_code/client.py:

  * ops_core.data_io.pathlib.AnyPath (line: 1)

If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. O
therwise, see <https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-depe>
ndencies for common problems.
The
--no-pantsd
is only so that the warning shows up every time, otherwise it’s suppressed after the first time
The output of
pants roots
is just
src
.
e

enough-analyst-54434

02/14/2023, 7:27 PM
Yeah
roots
are the issue
src/ is not the root
the two subroots are.
f

future-oxygen-10553

02/14/2023, 7:27 PM
OK, thanks! I actually just discovered that myself
The problem is that in the real repo, that doesn’t work 😄
e

enough-analyst-54434

02/14/2023, 7:28 PM
source roots == sys.path entries you need to make your code importable == PYTHONPATH for Python.
Ok, well more work to do on the real problem repro / debug then.
f

future-oxygen-10553

02/14/2023, 7:29 PM
Yep 😞 Thanks for the quick response again!
e

enough-analyst-54434

02/14/2023, 7:29 PM
Thanks for trying to make a repro case. That is really helpful.
f

future-oxygen-10553

02/14/2023, 7:30 PM
No problem. I’ve been an open-source maintainer for long enough that I get the pain of “THIS IS A PROBLEM” 🦗 😄
e

enough-analyst-54434

02/14/2023, 7:30 PM
I mean, you don't even need that. You just need a grandpa with a printer.
Who lives elsewhere.
f

future-oxygen-10553

02/14/2023, 7:32 PM
OK, I can repro again if I’m using resolves
I just pushed a new commit
I guess, reading the new error message, the question is how can I add first-party code to the
resolves
OK, I can
parametrize
the resolve in the
ops_core
package to cover
client_code
as well
Can that be auto-parametrized for all my source roots?
e

enough-analyst-54434

02/14/2023, 7:44 PM
Set up 1 BUILD file per source root that sets defaults.
f

future-oxygen-10553

02/14/2023, 7:48 PM
Hmm, I think that could work
We’d obviously have to keep it up-to-date as we add new resolves, but it should only happen in one or two places (I hope), so that’s not too bad
e

enough-analyst-54434

02/14/2023, 7:52 PM
Yeah, exactly. As simple as a comment in the
pants.toml
in the resolves section - "Update over here too.". And a mulligan to anyone who doesn't read the comment.
3 Views