Skip to main content

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

Project description

pip-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.0 branch, 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.dataclass instead 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_metadata backport.
    • This has been changed in the meantime. Please use piplicenses-lib<=0.4.1 if you need to support Python < 3.9.
  • Do not use abbreviations for naming purposes.
  • Rewrite tests to use plain unittest functionality.

Limitations

  • If you use this package in an environment with setuptools>=71, the results might be inconsistent if setuptools is imported before running pip-licenses-lib. This is due to setuptools modifying sys.path and inserting its vendored package path there. Upstream issue

Installation

You can install this package from PyPI:

python -m pip install pip-licenses-lib

Alternatively, you can use the package from source directly after installing the required dependencies.

Usage

The main entry point is piplicenses_lib.get_packages(), which will yield a list of package data objects.

License

This package is subject to the terms of the MIT license.

Disclaimer

All results are generated automatically from the data supplied by the corresponding package maintainers and provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. No generated content should be considered or used as legal advice. Consult an Attorney for any legal advice.

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_lib-1.2.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pip_licenses_lib-1.2.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pip_licenses_lib-1.2.0.tar.gz.

File metadata

  • Download URL: pip_licenses_lib-1.2.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pip_licenses_lib-1.2.0.tar.gz
Algorithm Hash digest
SHA256 90d7a1da6961863b6be517e191dd38299b9ca12edbd290da7cac7629a19ab736
MD5 9f3228c542633a38d1ebec2b9b512196
BLAKE2b-256 b9712099cb1d5c00648920ecd77c88d239ba4237dbe07645a1c1b4f52e27893d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pip_licenses_lib-1.2.0.tar.gz:

Publisher: release.yml on stefan6419846/pip-licenses-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pip_licenses_lib-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pip_licenses_lib-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 617670aab5674eee13c84e4f863823c847c57f7550d25e8129719486dc393c76
MD5 d42a527adc1a60f3e1397c0395cc6384
BLAKE2b-256 7b225be9ba85ff4b755394cea92f2729bf119a509b73dad1a6fc7ac2aedb2f27

See more details on using hashes here.

Provenance

The following attestation bundles were made for pip_licenses_lib-1.2.0-py3-none-any.whl:

Publisher: release.yml on stefan6419846/pip-licenses-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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