Support multiple source roots
JettJones opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
I'm trying to run deptry on a project/monorepo setup with https://www.pantsbuild.org/
This leads to some broken expectations
- no pyproject.toml exists. Pants.toml defines our build.
- internal projects use root_patterns for relative imports
So I can run deptry, and point to a shared requirements.txt
file, but without defining import paths, I'll end up with hundreds of errors like:
`DEP001 'internal_library' imported but missing from the dependency definitions
Describe the solution you would like
I'd like to be able to use deptry scanning directly with pants.toml defined requirements and multiple source paths. As a fall-back, being able to say give a broader PYTHONPATH like --source-roots ="./published/python:./libraries/python/"
would help.
Additional context
There's likely an extension of this ask to other build tools like bazel.
A solution that you could try today is using the known_first_party
flag. This should resolve your DEP001
errors.
I wonder if the use case/ask for pointing to multiple roots is then still big enough. If so, I think it would make sense to first create a generic solution that is not specific to Pants
. In this case, maybe an option would be to add include and extend-include flags, similar to ruff.
Then, if we want to support Pants.toml
, we could read the dependencies and sources from that file, and have sources
added to the include
flag. On the other hand, I am also a bit cautious to add support for Pants.toml
directly; It adds additional maintenance for a feature of which I am not sure it will be widely used. I guess that depends a bit on the amount of traction this issue gets.