Skip to main content

license-analyzer

SPDX license identification using hashes, fingerprints, and semantic similarity.
Supports command-line usage as well as Python module integration.


📦 Installation

pip install license-analyzer

To install from source (e.g., for development):

git clone https://github.com/yourorg/license-analyzer.git
cd license-analyzer
pip install .

🚀 Command-Line Usage

Once installed, the CLI tool is available as:

license-analyzer [OPTIONS] FILE [FILE...]

🔧 Common Options

Option Description
--top-n N Return top N matches per file. If omitted, returns all matches tied for highest score.
--format {text,json,csv} Output format. Default is text.
--min-score FLOAT Filter out matches with a score below this threshold (default: 0.0).
--spdx-dir DIR Path to SPDX license text files. Defaults to ~/.cache/license-analyzer/spdx/text.
--cache-dir DIR Path to cache directory for license database.
--embedding-model NAME SentenceTransformer model (default: all-MiniLM-L6-v2).
--update, -u Force update of SPDX license data from GitHub.
--verbose, -v Show progress and debug logs.

📄 Examples

Basic usage

license-analyzer LICENSE

Multiple files

license-analyzer license1.txt license2.txt

JSON output with top 3 matches

license-analyzer --format json --top-n 3 LICENSE

Force SPDX update

license-analyzer --update

🐍 Python Module Usage

You can also use license-analyzer directly in your Python code:

from license_analyzer.core import LicenseAnalyzer

analyzer = LicenseAnalyzer()
matches = analyzer.analyze_file("LICENSE")

for match in matches:
    print(match.name, match.score, match.method)

Or, if you want to analyze text (rather than a file):

text = open("LICENSE").read()
matches = analyzer.analyze_text(text)

for match in matches:
    print(match.name, match.score, match.method)

Use top_n=None to get all tied top-scoring matches:

matches = analyzer.analyze_text(text, top_n=None)

📈 Output Format (CLI)

Text (default)

Analysis results for: LICENSE
------------------------------------------------------------
MIT                            score: 1.0000  method: sha256

JSON

{
  "LICENSE": [
    {
      "name": "MIT",
      "score": 1.0,
      "method": "sha256"
    }
  ]
}

CSV

file_path,license_name,score,method
"LICENSE","MIT",1.0,"sha256"

🔄 Updating SPDX License Data

By default, license data is stored under:

~/.cache/license-analyzer/spdx

To update the SPDX license texts (from GitHub):

license-analyzer --update

This refreshes cached licenses and triggers database rebuild if needed.


🧠 Matching Strategies

  • ✅ SHA256 Hash Match
  • ✅ Canonical Fingerprint Match
  • ✅ Semantic Embedding Match (via sentence-transformers)

📝 License

SPDX-License-Identifier: Apache-2.0


Metadata

Release files for license-analyzer 0.0.4

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

Source distribution (sdist)

Source distribution for license-analyzer 0.0.4
File Size Uploaded Provenance
license_analyzer-0.0.4.tar.gz 27.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for license-analyzer 0.0.4
File Interpreter ABI Platform
license_analyzer-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 50.5 kB

Release files / license_analyzer-0.0.4.tar.gz

Download URL license_analyzer-0.0.4.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a9f43e968c664e5da9f28a0668bf3bcee41fdc39ab42a74c754bb8d5643667ba
BLAKE2b-256 checksum
How to use checksums
54b25b546dd685e52ae2ab6970fccbac346eb72ff84a7200c96b83f5933f63c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2025.

Transparency log

Release files / license_analyzer-0.0.4-py3-none-any.whl

Download URL license_analyzer-0.0.4-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96c8cb9027fbdefba6f83a0e314ee45e43173afc518f8db2a19dffb5ce58d4e5
BLAKE2b-256 checksum
How to use checksums
aae8113461bf8df9294ff869bad5ce8b1cf9c23475b1d9d0778bab4de9d598ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2025.

Transparency log

Security for license-analyzer 0.0.4

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for license_analyzer-0.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2025.

Transparency log

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.

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