cool-easter-32542
07/25/2023, 11:44 PM> pants dependencies --transitive apps/example-app-1
01:12:04.11 [WARN] The target libs/example-lib-core/example_lib_core/schema.py imports `pydantic.BaseModel`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['apps/example-app-2:poetry#pydantic', 'libs/example-lib-core:poetry#pydantic', 'libs/example-lib-extended:poetry#pydantic'].
Please explicitly include the dependency you want in the `dependencies` field of libs/example-lib-core/example_lib_core/schema.py, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.
Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to <https://www.pantsbuild.org/v2.16/docs/troubleshooting#import-errors-and-missing-dependencies>.
01:12:04.11 [WARN] Pants cannot infer owners for the following imports in the target libs/example-lib-core/example_lib_core/schema.py:
* pydantic.BaseModel (line: 1)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.16/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
According to documentation, I tried to specify exact dependencies source, the only way to do it for a whole package is via __default__, i.e. to specify that for all source files in the package libs/example-lib-core dependencies comes from particular pyproject.toml , I'm adding to `libs/example-lib-core/BUILD`:
__defaults__(all=dict(dependencies=["libs/example-lib-core:poetry"],))
poetry_requirements(
name="poetry",
)
It partially helps in example repo, only one warning is left (one gone):
> pants dependencies --transitive apps/example-app-1
00:57:22.42 [INFO] Initializing scheduler...
00:57:26.65 [INFO] Scheduler initialized.
00:57:28.15 [WARN] Pants cannot infer owners for the following imports in the target libs/example-lib-core/example_lib_core/schema.py:
* pydantic.BaseModel (line: 1)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.16/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
3rdparty/python/default.lock:_python-default_lockfile
apps/example-app-1/pyproject.toml:poetry
libs/example-lib-core/example_lib_core/schema.py
libs/example-lib-core/pyproject.toml:poetry
libs/example-lib-core:poetry#pydantic
what am I doing wrong?
Pants version
2.16.0
OS
MacOS
Additional info
1. I provided example of monorepo that I'm setting up, with explanation https://github.com/aimestereo/pants-monorepo-example
2. Seems, this issue is highly relevant: #17927 related PR: #17931
pantsbuild/pants