calm-librarian-70577
07/24/2024, 5:23 PM$ pants run projects/delta/src/delta/main.py
18:52:50.40 [WARN] The target projects/delta/src/delta/main.py imports `msgspec.json`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['projects/delta:poetry#msgspec', 'projects/gamma:poetry#msgspec'].
Please explicitly include the dependency you want in the `dependencies` field of projects/delta/src/delta/main.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/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies>.
18:52:50.40 [WARN] Pants cannot infer owners for the following imports in the target projects/delta/src/delta/main.py:
* msgspec.json (line: 3)
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/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies> for common problems.
18:52:51.06 [INFO] Completed: Building 1 requirement for delta.pex from the 3rdparty/python/default.lock resolve: click<9.0.0,>=8.1.7
Traceback (most recent call last):
File "/tmp/pants-sandbox-zRpAVd/./.cache/pex_root/venvs/3a7bcecec44d89cc814291af2f562c1aa5b28506/0de1795ad4486f45ee94cecd983e9905b6b11dc9/pex", line 320, in <module>
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/pants-sandbox-zRpAVd/projects/delta/src/delta/main.py", line 3, in <module>
import msgspec.json
ModuleNotFoundError: No module named 'msgspec'
For these roots:
$ pants roots
.
projects/delta/src
projects/gamma/src
I've been struggling with this for a few days now, with first- and third party dependencies.
That's technically correct, both gamma
and delta
have msgspec
as a 3rd party dependency.
But shouldn't source_roots
take care of this? They're in differnt roots. So why would delta
be concerned with reqs in gamma
. Yes, they share a resolve. And yes, it stops complaining if I split the resolves. But why should that matter?
The same problem occurs with 1st party:
19:04:57.23 [WARN] The target projects/delta/src/delta/main.py imports `omega.util.important_function_for_gamma`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['projects/delta/src/omega/util.py', 'projects/gamma/src/omega/util.py'].
Please explicitly include the dependency you want in the `dependencies` field of projects/delta/src/delta/main.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/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies>.
Traceback (most recent call last):
File "/tmp/pants-sandbox-fNU927/./.cache/pex_root/venvs/3a7bcecec44d89cc814291af2f562c1aa5b28506/0de1795ad4486f45ee94cecd983e9905b6b11dc9/pex", line 320, in <module>
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "<frozen runpy>", line 226, in run_module
File "<frozen runpy>", line 98, in _run_module_code
File "<frozen runpy>", line 88, in _run_code
File "/tmp/pants-sandbox-fNU927/projects/delta/src/delta/main.py", line 6, in <module>
from omega.util import important_function_for_gamma
ModuleNotFoundError: No module named 'omega'
Both delta
and gamma
have a package called omega
.
Here's the file tree:
.
├── 3rdparty
│ └── python
│ └── default.lock
├── pants.toml
└── projects
├── delta
│ ├── BUILD
│ ├── poetry.lock
│ ├── pyproject.toml
│ ├── src
│ │ ├── delta
│ │ │ ├── BUILD
│ │ │ ├── __init__.py
│ │ │ └── main.py
│ │ └── omega
│ │ ├── BUILD
│ │ ├── __init__.py
│ │ └── util.py
│ └── tests
│ ├── BUILD
│ ├── __init__.py
│ └── test_first.py
└── gamma
├── BUILD
├── poetry.lock
├── pyproject.toml
├── src
│ ├── gamma
│ │ ├── BUILD
│ │ ├── __init__.py
│ │ └── main.py
│ └── omega
│ ├── BUILD
│ ├── __init__.py
│ └── util.py
└── tests
├── BUILD
└── test_first.py
14 directories, 25 files
calm-librarian-70577
07/24/2024, 5:25 PMhappy-kitchen-89482
07/24/2024, 7:34 PMby_source_root
happy-kitchen-89482
07/24/2024, 7:35 PMnone
for backwards compatibility, but it's probably a good idea to change the default at this point.calm-librarian-70577
07/24/2024, 8:07 PMhappy-kitchen-89482
07/24/2024, 8:08 PM