How to use the tool when no virtual environment is being used?
rragundez opened this issue · 2 comments
I read that the tool needs to be ran within a virtual environment, but if I remember correctly, when building images on top of heavy ones (like custom ones to be ran on GPUs that already have the PyTorch magic setup) or installing dependencies for the CI the recommended practice is to use 'poetry config virtualenvs.create false'. How would I integrate this tool in such scenarios if there is no virtual environment?
An snippet example would be very helpful.
Hey Rodrigo! Thanks for raising the issue. The reason a virtual environment is required, is that deptry
needs access to the metadata of the package. For that purpose, deptry
needs to be installed in the same environment as your dependencies. If in CI/CD everything is installed globally instead of a virtual environment, this should not be an issue.
I created a small example here.
In this case:
pyproject.toml
does not listpytorch
as a dependencypytorch
is installed globally in the CI/CD workflow.poetry
is configured to not create a virtual environment in, see here.deptry
is configured to ignore the missing dependencypytorch
, see here.pandas
is listed as a dependency, but not imported.numpy
is listed as a dependency, and imported.
So the expected result is that we see one error: pandas
is listed as a dependency and not used. And indeed, the CI/CD workflow raises one issue, see here
Does this help and/or answer your question? If so, we could consider adding this or more examples to the documentation.
beautiful! Thanks a lot, this indeed suffices the use case. I think a lot of DS mature workflows in production would use pre-built images, this being Spark. I would imagine that having this example in the docs and informing the community can help to adopt deptry
easily durign CI.