raimon49 / pip-licenses

Dump the license list of packages installed with pip.
MIT License
307 stars 43 forks source link

reference using setuptools instead of pip internal #116

Closed tejaschumbalkar closed 1 year ago

tejaschumbalkar commented 2 years ago

Issue: #113

Reference function using setuptools instead of pip internal function. Reference: https://github.com/pypa/pip/issues/5243

raimon49 commented 2 years ago

Thanks for the information.

There is a part in the test code that mocks get_installed_distributions(). It needs to be fixed before merging.

jpmn commented 2 years ago

Any hope in seeing a fix for this issue merged in? Using pip=21.3.1, it throws an exception:

File ".venv\Scripts\pip-licenses.exe\__main__.py", line 4, in <module>
File ".venv\lib\site-packages\piplicenses.py", line 44, in <module>
  from pip import get_installed_distributions
ImportError: cannot import name 'get_installed_distributions' from 'pip' (.venv\lib\site-packages\pip\__init__.py)
raimon49 commented 2 years ago

@jpmn I haven't decided if I want to merge this PR or not.

Please install the latest version of pip-licenses in your environment and see if it solves the error.

# Update pip-licenses version to 3.5.3 or later
$ pip install -U pip-licenses
jpmn commented 2 years ago

I am using the latest version of pip-licenses, but I had to freeze my pip version until there is a fix. I might consider dropping the library in the medium-term if it is blocking my upgrade of pip.

Don't you experience the same behavior with more recent versions of pip?

worroc commented 2 years ago

This fix is required for many users, it is not acceptable to pin the pip version for a such long time. Is there road map to support pip >= 22?

raimon49 commented 2 years ago

@worroc Who are "many users"? If this is about you, we need information about your environment.

At least in my environment it is working with pip 22.x.

$ pip-licenses --with-system
 Name               Version   License
 PTable             0.9.2     BSD License
 botocore           1.21.53   Apache Software License
 jmespath           0.10.0    MIT License
 pip                22.2.2    MIT License
 pip-licenses       3.5.3     MIT License
raimon49 commented 1 year ago

This proposal was superseded by another excellent proposal that uses importlib_metadata.