Hi all, I’m trying to sort out some dependency man...
# general
f
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
Yeah
roots
are the issue
src/ is not the root
the two subroots are.
f
OK, thanks! I actually just discovered that myself
The problem is that in the real repo, that doesn’t work 😄
e
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
Yep 😞 Thanks for the quick response again!
e
Thanks for trying to make a repro case. That is really helpful.
f
No problem. I’ve been an open-source maintainer for long enough that I get the pain of “THIS IS A PROBLEM” 🦗 😄
e
I mean, you don't even need that. You just need a grandpa with a printer.
Who lives elsewhere.
f
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
Set up 1 BUILD file per source root that sets defaults.
f
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
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.