Skip to main content

Get the SPDX License ID from license text

Project description

LicenseID

PyPI - Version

A portable license ID matcher. Get the SPDX License ID from license text.

licenseid takes license text as input and identifies the closest matched SPDX License ID using a hybrid search strategy (trigram + token ratio ranking).

Features

  • Hybrid strategy:
    • Tier 1: Broad recall using SQLite FTS5 with trigram tokenization.
    • Tier 2: Precision ranking using RapidFuzz (token set ratio) + Popularity weighting.
    • Tier 3: Optional final validation via tools-java if available.
  • Unix philosophy: Parseable CLI output.

Installation

Install with pipx:

pipx install licenseid

Or using uv:

uv tool install licenseid

Usage

1. Update the license database

Before matching, you need to build the local license index:

licenseid update

Advanced update options:

  • --version <version>: Download a specific SPDX License List version (e.g., 3.26.0).
  • --force: Force update even if the local database is already at the target version.
  • --no-cache: Bypass the local cache for downloads.

2. Match a license

Identify license text from a file:

licenseid match LICENSE.txt

Or match from a string:

licenseid match --text "MIT License"

Common options:

  • --java: Enable Tier 3 Java validation (requires SPDX_TOOLS_JAR and jpype1).
  • --pop: Enable popularity weighting as a tie-breaker.
  • --json: Output results in JSON format.
  • --db <path>: Use a custom database path (global option).

The popularity tie-breaker is triggered when candidate similarity scores differ by less than 0.2%.

3. Cache management

licenseid maintains a local cache of remote data to save bandwidth.

  • licenses.json: Cached for 45 days.
  • popularity.csv: Cached for 75 days.
  • SPDX data tarballs are versioned and never expire.

To clear the cache manually:

licenseid --clear-cache

4. Output formats

Default (Unix-friendly):

LICENSE_ID=Apache-2.0 SCORE=0.9850

JSON:

licenseid match LICENSE.txt --json

Configuration

  • SPDX_TOOLS_JAR: Path to the tools-java jar for Tier 3 validation.

License

Apache-2.0

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

licenseid-0.1.1.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

licenseid-0.1.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file licenseid-0.1.1.tar.gz.

File metadata

  • Download URL: licenseid-0.1.1.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for licenseid-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bdebd3bf7bc9da63551b993771bf547e4fc1789895b536a884d774e426a72615
MD5 e354831b36722e9acde0a17fa2e5367b
BLAKE2b-256 c7cf593cc527b818f89ff5fcc6fbc974ac1d63d74c6d2e2d86c057c3b22553c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for licenseid-0.1.1.tar.gz:

Publisher: pypi-publish.yml on bact/licenseid

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

File details

Details for the file licenseid-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: licenseid-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for licenseid-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 133182f71c6cefea85eedbdb71171e39a89f3ce308fd20c3d0d512037b32030e
MD5 a3164fd2af7d62890a61a11c586d7f7b
BLAKE2b-256 098503e75eb8a3123e89a8ba689ef2290d58e51725d437aa92770cfe9f704f4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for licenseid-0.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on bact/licenseid

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