Skip to main content

Package and package stack license-solver for the Thoth project

Project description

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.:

{
   "requests": {
       "2.27.1": {
           "license": [
               "Apache License 2.0",
               "Apache-2.0",
               "Apache 2.0"
           ],
           "license_version": "2.0",
           "classifier": [
               [
                   "License :: OSI Approved :: Apache Software License",
                   "Apache Software License"
               ]
           ],
           "warning": false
       }
   }
}

  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.

{
   "requests": {
       "2.27.1": {
           "license": [
               "Apache License 2.0",
               "Apache-2.0",
               "Apache 2.0"
           ],
           "license_version": "2.0",
           "classifier": [
               [
                   "License :: OSI Approved :: Apache Software License",
                   "Apache Software License"
               ]
           ],
           "warning": false
       },
       "2.24.0": {
           "license": [
               "Apache License 2.0",
               "Apache-2.0",
               "Apache 2.0"
           ],
           "license_version": "2.0",
           "classifier": [
               [
                   "License :: OSI Approved :: Apache Software License",
                   "Apache Software License"
               ]
           ],
           "warning": false
       }
   }
}

  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.

{
   "numpy": {
       "1.22.1": {
           "license": [
               "BSD 4-Clause \"Original\" or \"Old\" License",
               "BSD-4-Clause",
               "BSD 4 Clause"
           ],
           "license_version": "4",
           "classifier": [
               [
                   "License :: OSI Approved :: BSD License",
                   "BSD License"
               ]
           ],
           "warning": false
       }
   },
   "requests": {
       "2.27.1": {
           "license": [
               "Apache License 2.0",
               "Apache-2.0",
               "Apache 2.0"
           ],
           "license_version": "2.0",
           "classifier": [
               [
                   "License :: OSI Approved :: Apache Software License",
                   "Apache Software License"
               ]
           ],
           "warning": false
       },
       "2.24.0": {
           "license": [
               "Apache License 2.0",
               "Apache-2.0",
               "Apache 2.0"
           ],
           "license_version": "2.0",
           "classifier": [
               [
                   "License :: OSI Approved :: Apache Software License",
                   "Apache Software License"
               ]
           ],
           "warning": false
       }
   }
}

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

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

thoth-license-solver-0.1.4.tar.gz (70.6 kB view details)

Uploaded Source

Built Distribution

thoth_license_solver-0.1.4-py3-none-any.whl (75.2 kB view details)

Uploaded Python 3

File details

Details for the file thoth-license-solver-0.1.4.tar.gz.

File metadata

  • Download URL: thoth-license-solver-0.1.4.tar.gz
  • Upload date:
  • Size: 70.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

File hashes

Hashes for thoth-license-solver-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e4b9c81c80bcb6d1c38b04410f57bdc18ffbfa9f45f3f3e4debcf2f394cfc819
MD5 64981c82b513fb6e1de8828c6f2c80d2
BLAKE2b-256 5abc5788017749c0c488c83ccf6d18287f5a6f7d01cc885d049efc95471814cb

See more details on using hashes here.

File details

Details for the file thoth_license_solver-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: thoth_license_solver-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 75.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8

File hashes

Hashes for thoth_license_solver-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6b491d95332b64def931844106ca32243afeda0e56c290da586cfa4f83f715c0
MD5 c4648f1e2453f7a373f9ff5b82e9331e
BLAKE2b-256 b76baa8e00139eb3ae1a3f327068eeebd9392c5b34bdcb9941e7e8d5fe3d40e9

See more details on using hashes here.

Supported by

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