raimon49 / pip-licenses

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

Inconsistent default behavior of --summary option #93

Closed johnthagen closed 3 years ago

johnthagen commented 3 years ago

Consider the following virtual environment:

$ python -m pip list
Package                       Version
----------------------------- ----------
alabaster                     0.7.12
appdirs                       1.4.4
atomicwrites                  1.4.0
attrs                         20.2.0
Babel                         2.8.0
black                         20.8b1
certifi                       2020.6.20
chardet                       3.0.4
click                         7.1.2
colorama                      0.4.4
coverage                      5.3
distlib                       0.3.1
docutils                      0.16
exitstatus                    2.0.1
filelock                      3.0.12
flake8                        3.8.4
flake8-polyfill               1.0.2
idna                          2.10
imagesize                     1.2.0
iniconfig                     1.1.1
isort                         5.6.4
Jinja2                        2.11.2
MarkupSafe                    1.1.1
mccabe                        0.6.1
mypy                          0.790
mypy-extensions               0.4.3
packaging                     20.4
pathspec                      0.8.0
pep8-naming                   0.11.1
pip                           21.0.1
pip-licenses                  3.3.0
pip-tools                     5.3.1
pluggy                        0.13.1
PTable                        0.9.2
py                            1.9.0
pycodestyle                   2.6.0
pyflakes                      2.2.0
Pygments                      2.7.2
pyparsing                     2.4.7
pytest                        6.1.2
pytest-cov                    2.10.1
pytz                          2020.1
regex                         2020.10.28
requests                      2.24.0
setuptools                    50.3.0
six                           1.15.0
snowballstemmer               2.0.0
Sphinx                        3.2.1
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        1.0.3
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.4
toml                          0.10.1
tox                           3.20.1
typed-ast                     1.4.1
typing-extensions             3.7.4.3
urllib3                       1.25.11
virtualenv                    20.1.0

Running pip-licenses produces pleasant output:

$ pip-licenses
 Name                           Version     License
 Babel                          2.8.0       BSD License
 Jinja2                         2.11.2      BSD License
 MarkupSafe                     1.1.1       BSD License
 Pygments                       2.7.2       BSD License
 Sphinx                         3.2.1       BSD License
 alabaster                      0.7.12      BSD License
 appdirs                        1.4.4       MIT License
 atomicwrites                   1.4.0       MIT License
 attrs                          20.2.0      MIT License
 black                          20.8b1      MIT License
 certifi                        2020.6.20   Mozilla Public License 2.0 (MPL 2.0)
 chardet                        3.0.4       GNU Library or Lesser General Public License (LGPL)
 click                          7.1.2       BSD License
 colorama                       0.4.4       BSD License
 coverage                       5.3         Apache Software License
 distlib                        0.3.1       Python Software Foundation License
 docutils                       0.16        Public Domain, Python Software Foundation License, BSD License, GNU General Public License (GPL)
 exitstatus                     2.0.1       MIT License
 filelock                       3.0.12      Public Domain
 flake8                         3.8.4       MIT License
 flake8-polyfill                1.0.2       MIT License
 idna                           2.10        BSD License
 imagesize                      1.2.0       MIT License
 iniconfig                      1.1.1       MIT License
 isort                          5.6.4       MIT License
 mccabe                         0.6.1       MIT License
 mypy                           0.790       MIT License
 mypy-extensions                0.4.3       MIT License
 packaging                      20.4        Apache Software License, BSD License
 pathspec                       0.8.0       Mozilla Public License 2.0 (MPL 2.0)
 pep8-naming                    0.11.1      MIT License
 pip-tools                      5.3.1       BSD License
 pluggy                         0.13.1      MIT License
 py                             1.9.0       MIT License
 pycodestyle                    2.6.0       MIT License
 pyflakes                       2.2.0       MIT License
 pyparsing                      2.4.7       MIT License
 pytest                         6.1.2       MIT License
 pytest-cov                     2.10.1      BSD License
 pytz                           2020.1      MIT License
 regex                          2020.10.28  Apache Software License
 requests                       2.24.0      Apache Software License
 six                            1.15.0      MIT License
 snowballstemmer                2.0.0       BSD License
 sphinxcontrib-applehelp        1.0.2       BSD License
 sphinxcontrib-devhelp          1.0.2       BSD License
 sphinxcontrib-htmlhelp         1.0.3       BSD License
 sphinxcontrib-jsmath           1.0.1       BSD License
 sphinxcontrib-qthelp           1.0.3       BSD License
 sphinxcontrib-serializinghtml  1.1.4       BSD License
 toml                           0.10.1      MIT License
 tox                            3.20.1      MIT License
 typed-ast                      1.4.1       Apache License 2.0
 typing-extensions              3.7.4.3     Python Software Foundation License
 urllib3                        1.25.11     MIT License
 virtualenv                     20.1.0      MIT License

But the --summary option seems to generate a different set of license string names (almost as if --from=mixed isn't used (#60)):

$ pip-licenses --summary
 Count  License
 2      Apache 2.0
 1      Apache License 2.0
 1      Apache Software License
 10     BSD
 1      BSD License
 1      BSD-2-Clause or Apache-2.0
 4      BSD-3-Clause
 1      BSD-like
 3      Expat license
 1      LGPL
 18     MIT
 4      MIT License
 2      MIT license
 1      MPL 2.0
 1      MPL-2.0
 1      PSF
 1      Public Domain <http://unlicense.org>
 1      Python license
 1      UNKNOWN
 1      public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)

I would expect pip-licenses --summary to output an aggregated list of licenses using the license string names shown in pip-licenses. This has the advantage that the --from=mixed names are much more uniform, and thus group more nicely.

cdce8p commented 3 years ago

I opened a PR to fix this issue. See #94

johnthagen commented 3 years ago

@cdce8p Thanks!