Skip to main content

pylic - Python license checker GitHub license PyPI version

A Python license checker. pylic is PEP-639-compliant and supports the SPDX License Expression syntax.

Principles:

  • All licenses of all installed packages are relevant.
  • All installed packages without a license are considered unsafe and have to be listed as such.
  • Every license has to be allowed explicitly.

Installation

Requires Python 3.11 or newer. Tested on Python 3.11–3.15.

pip install pylic

Configuration

pylic needs be run in the directory where your pyproject.toml file is located. You can configure

  • safe_licenses: All licenses you consider safe for usage. The string comparison is case-insensitive.
  • unsafe_packages: List packages that have no license or use licenses not considered safe.
[tool.pylic]
safe_licenses = [
    "Apache Software License",
    "Apache License 2.0",
    "MIT License",
    "Python Software Foundation License",
    "Mozilla Public License 2.0 (MPL 2.0)",
]
unsafe_packages = [
    "unsafe_package",
]

Commands

pylic provides the following commands (also see pylic --help):

  • check: Checks all installed licenses.
  • list: Lists all installed packages and their corresponding license.

Usage Example

Create a venv to start with a clean ground and activate it

python -m venv .venv
source .venv/bin/activate

Install pylic and create an empty pyproject.toml

pip install pylic
touch pyproject.toml

Install all your dependencies

pip install <packageA> <packageB>

Run pylic

pylic check

The output will be similar to

Found unsafe packages:
  pkg_resources (0.0.0)
Found unsafe licenses:
  pip (18.1): MIT License
  zipp (3.4.1): MIT License
  toml (0.10.2): MIT License
  pylic (1.2.0): MIT License
  setuptools (40.8.0): MIT License
  typing-extensions (3.7.4.3): Python Software Foundation License
  importlib-metadata (3.9.0): Apache Software License

The return code of pylic is in this case non-zero due to unsafe licenses. This allows usage of pylic in CI.

echo $? # prints 1

As these licenses and packages are all ok we can configure pylic accordingly

cat <<EOT >> pyproject.toml
[tool.pylic]
safe_licenses = ["Apache Software License", "MIT License", "Python Software Foundation License"]
unlicensed_packages = ["pkg_resources"]
EOT

After rerunning pylic check the output now reveals a successful validation

✨ All licenses ok ✨

Also the return code now signals that all is good

echo $? # prints 0

Use pylic list to list all installed packages and their corresponding licenses.

Advanced Usage

In cases where the safe licenses or unsafe packages are centrally managed keeping the configuration in perfect sync to the installed packages might be too cumbersome or even impossible. To support these use cases the check command provides the two options (see also check --help) --allow-extra-safe-licenses and --allow-extra-unsafe-packages. These options only affect the returned status code and will keep all corresponding warnings unchanged.

Pre-commit

pylic provides a pre-commit integration. Follow the instructions and enable automatic license checking on commits by adding

-  repo: https://github.com/ubersan/pylic
   rev: v<version>
   hooks:
   -  id: pylic

to your .pre-commit-config.yaml file.

Development

Required tools:

Run uv sync to install all necessary dependencies, including just (provided by the rust-just package) and ty. Utility tasks are defined in the justfile and can be run with uv run just <recipe>. Run uv run just --list to list available recipes, uv run just check for all quality checks, or uv run just test for the tests.

Creating a new release is as simple as:

  • Update version in the pyproject.toml and the __version__.py file.
  • Run git tag <new-version>.
  • Run git push origin <new-version>.

Metadata

Release files for pylic 6.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylic 6.2.0
File Size Uploaded Provenance Actions
pylic-6.2.0.tar.gz 18.2 kB Without provenance Details for pylic-6.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylic 6.2.0
File Interpreter ABI Platform Actions
pylic-6.2.0-py3-none-any.whl Python 3 none any Details for pylic-6.2.0-py3-none-any.whl

Total release size: 25.8 kB

Release files / pylic-6.2.0.tar.gz

Download URL pylic-6.2.0.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1c8fb7d5812ecf150f8b366d5b5a9f3be5c5de089acd589a5afde7e687c14ad4
BLAKE2b-256 checksum
How to use checksums
56afd9aa11cd36a02734b45e5dbbc0c67c3a8097d57aefc107fbed2a554be9d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylic-6.2.0-py3-none-any.whl

Download URL pylic-6.2.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ec087359f2ef04f2ec10cfb49b622d8c106adee69491fd15e53cf5f21cf845d
BLAKE2b-256 checksum
How to use checksums
e6dd0386ed1bd4b394729c66374128e2c16a62731200c09d2b0faa48278a7789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pylic 6.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page