You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we can only get packages from the environments we are running pip-licenses on. This is a problem for two reasons
As said in mentioned issue, we cannot use it as a pre-commit hook easily. There is the possibility to use a hook within the activated environment, but it's clearly not following its guidelines
Using this libraries implies installing it in your venv, and thus contaminating it by installing packages you wouldn't need otherwise. It's no great given the purpose of this lib is to identify licenses of installed packages
Somehow related to #107
Currently, we can only get packages from the environments we are running pip-licenses on. This is a problem for two reasons
I think there is a simple fix to this.
Indeed, thepckages are discovered via
importlib
distributions()
function. As it can be seen here : https://github.com/raimon49/pip-licenses/blob/master/piplicenses.py#L193By looking at the documentation and code of importlib, it seems to me that
distributions
should accept apath
argument with a list of folders to search into.See
https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.distributions
and https://github.com/python/importlib_metadata/blob/700f2c7d74543e3695163d5487155b92e6f04d65/importlib_metadata/__init__.py#L809
distributions(**kwargs)
callsDistribution.discover(**kwargs)
which expects either aContext
object or its args for creating one (see https://github.com/python/importlib_metadata/blob/700f2c7d74543e3695163d5487155b92e6f04d65/importlib_metadata/__init__.py#L387 )All in all, calling
distributions([folder_path])
will retrieve all packages metadata in the givenfolder_path
which could be a CLI parameter.What do you think ?
The text was updated successfully, but these errors were encountered: