raimon49 / pip-licenses

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

pip-licenses broken in python 3.11 #128

Closed b-kamphorst closed 1 year ago

b-kamphorst commented 1 year ago

pip-licenses is broken in python 3.11 for pip>=22.1.

The issue is roughly the same as in #113. Log:

$ pip-licenses
Traceback (most recent call last):
  File "/builds/gitlab/.../.venv/bin/pip-licenses", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/builds/gitlab/.../stubs/.venv/lib/python3.11/site-packages/piplicenses.py", line 900, in main
    output_string = create_output_string(args)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/gitlab/.../stubs/.venv/lib/python3.11/site-packages/piplicenses.py", line 558, in create_output_string
    table = create_licenses_table(args, output_fields)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/gitlab/.../stubs/.venv/lib/python3.11/site-packages/piplicenses.py", line 303, in create_licenses_table
    for pkg in get_packages(args):
  File "/builds/gitlab/.../stubs/.venv/lib/python3.11/site-packages/piplicenses.py", line 2[54](...), in get_packages
    pkg_name = pkg.project_name
               ^^^^^^^^^^^^^^^^
AttributeError: 'PathDistribution' object has no attribute 'project_name'
b-kamphorst commented 1 year ago

https://github.com/raimon49/pip-licenses/pull/116 attempts to solve this issue with setuptools. I'm no expert, but perhaps importlib.metadata can be considered (built-in)?

raimon49 commented 1 year ago

A release candidate version that works well with Python 3.11 is available thanks to bart's contribution. https://pypi.org/project/pip-licenses/4.0.0rc1/

Users who wish to try this version before the official release should install it with pip.Feedback on running it in different environments is welcome.

$ pip install 'pip-licenses==4.0.0rc1'   
nejch commented 1 year ago

@raimon49 I just opened this issue and your comment popped up a few seconds after :)

I installed the rc1 and this works for me on 3.11.

raimon49 commented 1 year ago

RC2 is now available following bug reports and patches. #132

pip install 'pip-licenses==4.0.0rc2'

We continue to welcome feedback.

raimon49 commented 1 year ago

pip-licenses 4.0.0 has been officially released. Thank you all for your contributions. https://pypi.org/project/pip-licenses/4.0.0/