Retrieve the software license list of Python packages installed with pip.
Actively maintained. Last release 7 months ago, commits in 26 of the last 26 weeks. A safe choice.
pip install pip-licenses-libpip-licenses Library
Retrieve the software license list of Python packages installed with pip.
If you are looking for a CLI based upon this library which is compatible with pip-licenses, you might want to have a look at pip-licenses-cli.
About
This package is a fork of the great pip-licenses tool, which provides a CLI with similar functionality. For now, pip-licenses itself mostly focuses on the CLI part; while library-based access is possible, some interesting methods for further reuse are nested and therefore hidden inside the corresponding API.
While there have been some attempts to provide similar features in the upstream repository, they are not available inside the official package at the moment, while I needed a short-term solution. Examples:
- In May 2021, a package structure has been introduced by #88. In August 2023, this is still only available on a
dev-4.0.0branch, while version 4.0.0 has been released in November 2022. - In October 2020, the PR #78 for handling multiple license files has been closed to maybe include it in the future, which has not yet happened.
As parsing the license data of packages as provided by the maintainers is at least some first hint regarding the license status, I decided to create this fork with the required modifications and enhancements to suit my current needs.
Differences to pip-licenses
Changes compared to the original version:
- Use
dataclasses.dataclassinstead of a dictionary for each package information result. - Remove all output/rendering functionality.
- Move all methods to the top level.
- Always return all copyright and notice file matches.
- Always return the system packages as well.
- Add support for newer standards like PEP 639.
- Include the license names and distribution object inside the results.
- Add an option to skip retrieving license and notice files for faster version-only checks.
- Add an option to normalize returned package names.
- Enable support for Python < 3.8 by using the
importlib_metadatabackport.- This has been changed in the meantime. Please use if you need to support Python < 3.9.