/license-solver

Detect license information from Python package metadata as provided by thoth-solver

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

License solver

Welcome to Thoth's license-solver repository!

This tool handles license and classifier detection from metadata provided by PyPI. Determines the type of license and its version. It also indicates a discrepancy in the license and in the classifier.

What license-solver does

Detects licenses and classifier from metadata provided by:

  • PyPI
  • JSON files
  • folders with JSON files
  • dictionary (with function detect_license())

The output is printed by default on STDOUT (you can choose the file where to save the output more in --help).

Good to know

  • unidentified license/version/classifier are named UNDETECTED
  • non-versioned licenses have an identifier in license_version LICENSE-WITHOUT-VERSION

Run solver locally

Often, it is useful to run license-solver locally to experiment or verify your changes in implementation. You can do so easily by running:

$ PYTHONPATH=. python3 ./thoth-license-solver <arguments>

Examples

  1. sample with 1 file:
$ thoth-license-solver --file tests/examples/request_example.json -pp 4
  • Output 1.:

  1. sample with 2 files with the same package but with different versions:
$ thoth-license-solver --file tests/examples/request_example.json tests/examples/request_example_2.json -pp 4
  • Output 2.

  1. sample with 2 files with the same package but with different versions and with 1 different PyPI package:
$ thoth-license-solver --file tests/examples/request_example.json tests/examples/request_example_2.json --package-name numpy -pp 4
  • Output 3.

Installation

Install `license-solver`:

$ pip install thoth-license-solver

Run tests

It is a good habit for the program to be tested after the implementation of new features. You can run:

$ pytest tests/
# or
$ pytest --cov-report term-missing --cov=thoth tests/     # coverage test

Special aliases