Skip to main content

Dump the software license list of Python packages installed with pip.

Project description

Build Status PyPI - Python Version PyPI version GitHub Release Codecov BSD License Requirements Status

Dump the software license list of Python packages installed with pip.

Table of Contents

Description

pip-licenses is a CLI tool for checking the software license of installed Python packages with pip.

Implemented with the idea inspired by composer licenses command in Composer (a.k.a PHP package management tool).

https://getcomposer.org/doc/03-cli.md#licenses

Installation

Install it via PyPI using pip command.

# Install or Upgrade to newest available version
$ pip install -U pip-licenses

Usage

Execute the command with your venv (or virtualenv) environment.

# Install packages in your venv environment
(venv) $ pip install Django pip-licenses

# Check the licenses with your venv environment
(venv) $ pip-licenses
 Name    Version  License
 Django  2.0.2    BSD
 pytz    2017.3   MIT

Command-Line Options

Option: from-classifier

By default, this tool finds the license from package Metadata. However, depending on the type of package, it does not declare a license only in the Classifiers.

(See also): Set license to MIT in setup.py by alisianoi ・ Pull Request #1058 ・ pypa/setuptools, PEP 314#License

For example, even if you check with the pip show command, the license is displayed as UNKNOWN.

(venv) $ pip show setuptools
Name: setuptools
Version: 38.5.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: distutils-sig@python.org
License: UNKNOWN

If you want to refer to the license declared in the Classifiers, use the --from-classifier option.

(venv) $ pip-licenses --from-classifier --with-system
 Name          Version  License
 Django        2.0.2    BSD License
 PTable        0.9.2    BSD License
 pip           9.0.1    MIT License
 pip-licenses  1.0.0    MIT License
 pytz          2017.3   MIT License
 setuptools    38.5.0   MIT License

Option: with-system

By default, system packages such as pip and setuptools are ignored.

If you want to output all including system package, use the --with-system option.

(venv) $ pip-licenses --with-system
 Name          Version  License
 Django        2.0.2    BSD
 PTable        0.9.2    BSD (3 clause)
 pip           9.0.1    MIT
 pip-licenses  1.0.0    MIT License
 pytz          2017.3   MIT
 setuptools    38.5.0   UNKNOWN

Option: with-authors

When executed with the --with-authors option, output with author of the package.

(venv) $ pip-licenses --with-authors
 Name    Version  License  Author
 Django  2.0.2    BSD      Django Software Foundation
 pytz    2017.3   MIT      Stuart Bishop

Option: with-urls

For packages without Metadata, the license is output as UNKNOWN. To get more package information, use the --with-urls option.

(venv) $ pip-licenses --with-urls
 Name    Version  License  URL
 Django  2.0.2    BSD      https://www.djangoproject.com/
 pytz    2017.3   MIT      http://pythonhosted.org/pytz

Option: with-description

When executed with the --with-description option, output with short description of the package.

(venv) $ pip-licenses --with-description
 Name    Version  License  Description
 Django  2.0.2    BSD      A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
 pytz    2017.3   MIT      World timezone definitions, modern and historical

Option: with-license-file

When executed with the --with-license-file option, output the location of the package’s license file on disk and the full contents of that file. Due to the length of these fields, this option is best paired with --format-json.

Option: ignore-packages

When executed with the --ignore-packages option, ignore the package specified by argument from list output.

(venv) $ pip-licenses --ignore-packages django
 Name  Version  License
 pytz  2017.3   MIT

Package names of arguments can be separated by spaces.

(venv) $ pip-licenses --with-system --ignore-packages django pip pip-licenses
 Name        Version  License
 PTable      0.9.2    BSD (3 clause)
 pytz        2017.3   MIT
 setuptools  38.5.0   UNKNOWN

Option: order

By default, it is ordered by package name.

If you give arguments to the --order option, you can output in other sorted order.

(venv) $ pip-licenses --order=license

Option: format-markdown

When executed with the --format-markdown option, you can output list in markdown format.

(venv) $ pip-licenses --format-markdown
| Name   | Version | License |
|--------|---------|---------|
| Django | 2.0.2   | BSD     |
| pytz   | 2017.3  | MIT     |

When inserted in a markdown document, it is rendered as follows:

Name

Version

License

Django

2.0.2

BSD

pytz

2017.3

MIT

Option: format-rst

When executed with the --format-rst option, you can output list in “Grid tables” of reStructuredText format.

(venv) $ pip-licenses --format-rst
+--------+---------+---------+
| Name   | Version | License |
+--------+---------+---------+
| Django | 2.0.2   | BSD     |
+--------+---------+---------+
| pytz   | 2017.3  | MIT     |
+--------+---------+---------+

Option: format-confluence

When executed with the --format-confluence option, you can output list in Confluence (or JIRA) Wiki markup format.

(venv) $ pip-licenses --format-confluence
| Name   | Version | License |
| Django | 2.0.2   | BSD     |
| pytz   | 2017.3  | MIT     |

Option: format-html

When executed with the --format-html option, you can output list in HTML table format.

(venv) $ pip-licenses --format-html
<table>
    <tr>
        <th>Name</th>
        <th>Version</th>
        <th>License</th>
    </tr>
    <tr>
        <td>Django</td>
        <td>2.0.2</td>
        <td>BSD</td>
    </tr>
    <tr>
        <td>pytz</td>
        <td>2017.3</td>
        <td>MIT</td>
    </tr>
</table>

Option: format-json

When executed with the --format-json option, you can output list in JSON format
easily allowing post-processing
[
  {
    "Author": "Django Software Foundation",
    "License": "BSD",
    "Name": "Django",
    "URL": "https://www.djangoproject.com/",
    "Version": "2.0.2"
  },
  {
    "Author": "Stuart Bishop",
    "License": "MIT",
    "Name": "pytz",
    "URL": "http://pythonhosted.org/pytz",
    "Version": "2017.3"
  }
]

Option: summary

When executed with the --summary option, you can output a summary of each license.

(venv) $ pip-licenses --summary --from-classifier --with-system
 Count  License
 2      BSD License
 4      MIT License

Note: When using this option, only --order=count or --order=license has an effect for the --order option. And using --with-authors and --with-urls will be ignored.

More Information

Other, please make sure to execute the --help option.

License

MIT License

Dependencies

  • PTable by Luke Maurits and maintainer of fork version Kane Blueriver under the BSD-3-Clause License

pip-licenses has been implemented in the policy to minimize the dependence on external package.

Uninstallation

Uninstall package and dependent package with pip command.

$ pip uninstall pip-licenses PTable

CHANGELOG

1.11.0

  • Implement new option --with-license-file

1.10.0

  • Implement new option --with-description

1.9.0

  • Implement new option --summary

1.8.0

  • Implement new option --format-json

  • Dropped support Python 3.3

1.7.1

  • Fix bug

    • Support pip 10.x

1.7.0

  • Implement new option --format-confluence

1.6.1

  • Fix bug

    • Support display multiple license with --from-classifier option

  • Improve document

    • Add section of ‘Uninstallation’ in README

1.6.0

  • Implement new option --format-html

1.5.0

  • Implement new option --format-rst

1.4.0

  • Implement new option --format-markdown

  • Include LICENSE file in distribution package

1.3.0

  • Implement new option --ignore-packages

1.2.0

  • Implement new option --from-classifier

1.1.0

  • Improve document

    • Add ToC to README document

    • Add a information of dependencies

1.0.0

  • First stable release version

0.2.0

  • Implement new option --order

    • Default behavior is --order=name

0.1.0

  • First implementation version

    • Support options

      • --with-system

      • --with-authors

      • --with-urls

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pip-licenses-1.11.0.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

pip_licenses-1.11.0-py2.py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page