cool-easter-32542
06/30/2024, 5:30 AMpyproject.toml. Therefore, lots of 3rd party dependencies throw the error:
Pants cannot safely infer a dependency because more than one target owns this module
It doesn't seem to make sense to create separate resolves for each python directory, because versions are shared across all submodules to guarantee compatibility.
Describe the solution you'd like
Each of my python_source/python_test targets have only 1 poetry_requirements in the parent directory tree. It seems reasonable that if a dependency is declared only once in the parent directory tree, it could be assumed to be the owner.
For example:
.
├── pants.toml
├── module_foo/
│ ├── pyproject.toml # declares `pytest` dependency
│ └── src/
│ └── foo_test.py # should infer `pytest` dependency is owned by `module_foo:poetry#pytest`
└── module_bar/
├── pyproject.toml # declares `pytest` dependency (same version as module_foo)
└── src/
└── bar_test.py # should infer `pytest` dependency is owned by `module_bar:poetry#pytest`
Describe alternatives you've considered
Otherwise, I'd have to explicitly add dependencies to 900+ targets in my repo:
➜ pants list :: --filter-target-type=python_sources,python_tests | wc -l
903
Additional context
This could/should be optional behavior in either dependency declaration (ie poetry_requirements(recursive=true)) or in the dependency consumer (ie python_sources(modules_from_parent_dirs=true), or could be configured globally in pants.toml
pantsbuild/pantscool-easter-32542
06/30/2024, 5:02 PM