Skip to main content

GitHub top language Repository size Issues License Commit activity Last commit PyPI Downloads PyPI Total Downloads PyPI Version

LicenseCheck

Project Icon

Output the licences used by dependencies and check if these are compatible with the project license

Table of Contents

Examples from the command-line

See below for the output if you run licensecheck in this directory

Without metprint

>> licensecheck
┌──────────┬────────────────────┬────────────────────┐
│Compatible│Package             │License             │
├──────────┼────────────────────┼────────────────────┤
│True      │attrs               │MIT License         │
│True      │certifi             │Mozilla Public Licen│
│True      │charset-normalizer  │MIT License         │
│True      │fhconfparser        │MIT License         │
│True      │idna                │BSD License         │
│True      │metprint            │MIT License         │
│True      │requests            │Apache Software Lice│
│True      │requirements-parser │BSD License         │
│True      │tomlkit             │MIT License         │
│True      │urllib3             │MIT License         │
└──────────┴────────────────────┴────────────────────┘

With metprint

If metprint is installed the tables look slightly different (note that the leftmost symbols are coloured in the terminal)

>> licensecheck
    ┌────────────────────┬──────────────────────────────┐
    │Package             │License                       │
    ├────────────────────┼──────────────────────────────┤
[+] │attrs               │MIT License                   │
[+] │certifi             │Mozilla Public License 2.0 (MP│
[+] │charset-normalizer  │MIT License                   │
[+] │idna                │BSD License                   │
[+] │metprint            │MIT License                   │
[+] │requests            │Apache Software License       │
[+] │requirements-parser │BSD License                   │
[+] │tomlkit             │MIT License                   │
[+] │urllib3             │MIT License                   │
    └────────────────────┴──────────────────────────────┘

Using requirements

>> licensecheck -u requirements
    ┌────────────────────┬──────────────────────────────┐
    │Package             │License                       │
    ├────────────────────┼──────────────────────────────┤
[+] │fhconfparser        │MIT License                   │
[+] │metprint            │MIT License                   │
[+] │pip                 │MIT License                   │
[+] │requests            │Apache Software License       │
[+] │requirements-parser │BSD License                   │
[+] │tomlkit             │MIT License                   │
    └────────────────────┴──────────────────────────────┘

Failing on packages under MIT license

>> licensecheck --fail-licenses mit
    ┌────────────────────┬──────────────────────────────┐
    │Package             │License                       │
    ├────────────────────┼──────────────────────────────┤
[-] │attrs               │MIT License                   │
[+] │certifi             │Mozilla Public License 2.0 (MP│
[-] │charset-normalizer  │MIT License                   │
[-] │fhconfparser        │MIT License                   │
[+] │idna                │BSD License                   │
[-] │metprint            │MIT License                   │
[+] │requests            │Apache Software License       │
[+] │requirements-parser │BSD License                   │
[-] │tomlkit             │MIT License                   │
[-] │urllib3             │MIT License                   │
    └────────────────────┴──────────────────────────────┘

Custom requirements.txt in json format

Add optional path to requirements.txt as outlined in https://github.com/FHPythonUtils/LicenseCheck/issues/9#issuecomment-898878228. Eg. licensecheck --using requirements:c:/path/to/reqs.txt;path/to/other/reqs.txt

>> licensecheck -u 'requirements:requirements.txt;requirements_optional.txt' -f json
{
	"heading": "# Packages - Find a list of packages below",
	"packages": [
			{
					"name": "fhconfparser",
					"version": "2021.1.1",
					"namever": "fhconfparser 2021.1.1",
					"home_page": "https://github.com/FHPythonUtils/FHConfParser",
					"author": "FredHappyface",
					"size": 9241,
					"license": "MIT License",
					"license_compat": true
			},
			...
			{
					"name": "tomlkit",
					"version": "0.7.2",
					"namever": "tomlkit 0.7.2",
					"home_page": "https://github.com/sdispater/tomlkit",
					"author": "S\u00e9bastien Eustace",
					"size": 11653,
					"license": "MIT License",
					"license_compat": true
			}
	]
}

Poetry with dev requirements

Add -u poetry:dev to command-line to include dev packages (excluded by default)

>> licensecheck -u poetry:dev
    ┌────────────────────┬──────────────────────────────┐
    │Package             │License                       │
    ├────────────────────┼──────────────────────────────┤
[+] │attrs               │MIT License                   │
[+] │certifi             │Mozilla Public License 2.0 (MP│
[+] │charset-normalizer  │MIT License                   │
[+] │idna                │BSD License                   │
[+] │metprint            │MIT License                   │
[+] │requests            │Apache Software License       │
[+] │requirements-parser │BSD License                   │
[+] │tomlkit             │MIT License                   │
[+] │urllib3             │MIT License                   │
    └────────────────────┴──────────────────────────────┘

Help

usage: __main__.py [-h] [--format FORMAT] [--file FILE] [--using USING]
                   [--ignore-packages IGNORE_PACKAGES [IGNORE_PACKAGES ...]]
                   [--fail-packages FAIL_PACKAGES [FAIL_PACKAGES ...]]
                   [--ignore-licenses IGNORE_LICENSES [IGNORE_LICENSES ...]]
                   [--fail-licenses FAIL_LICENSES [FAIL_LICENSES ...]] [--zero]

Output the licenses used by dependencies and check if these are compatible with the project license.

optional arguments:
  -h, --help            show this help message and exit
  --format FORMAT, -f FORMAT
                        Output format. one of: json, markdown, csv, ansi, simple. default=simple
  --file FILE, -o FILE  Filename to write to (omit for stdout)
  --using USING, -u USING
                        Environment to use e.g. requirements.txt. one of: requirements, poetry. default=poetry
  --ignore-packages IGNORE_PACKAGES [IGNORE_PACKAGES ...]
                        a list of packages to ignore (compat=True)
  --fail-packages FAIL_PACKAGES [FAIL_PACKAGES ...]
                        a list of packages to fail (compat=False)
  --ignore-licenses IGNORE_LICENSES [IGNORE_LICENSES ...]
                        a list of licenses to ignore (skipped, compat may still be False)
  --fail-licenses FAIL_LICENSES [FAIL_LICENSES ...]
                        a list of licenses to fail (compat=False)
  --zero, -0            Return non zero exit code if an incompatible license is found

You can also import this into your own project and use any of the functions in the DOCS

Configuration Example

Configuration files are parsed in the following order: pyproject.toml, setup.cfg, licensecheck.toml, licensecheck.json, licensecheck.ini, ~/licensecheck.toml, ~/licensecheck.json, ~/licensecheck.ini

  • ⚠ All config files are parsed, however configuration defined in previous files takes precedent

Add optional path to requirements.txt as outlined in https://github.com/FHPythonUtils/LicenseCheck/issues/9#issuecomment-898878228 for example: licensecheck --using requirements:c:/path/to/reqs.txt;path/to/other/reqs.txt

Example 1: pyproject.toml

The following config is equivalent to licensecheck -u 'requirements:requirements.txt;requirements_optional.txt' -f json

[tool.licensecheck]
using = "requirements:requirements.txt;requirements_optional.txt"
format = "json"

Example 2: licensecheck.json

The following config is equivalent to licensecheck -u 'requirements:requirements.txt;requirements_optional.txt' -f json

{
	"tool": {
		"licensecheck": {
			"using": "requirements:requirements.txt;requirements_optional.txt",
			"format": "json"
		}
	}
}

Example 3: licensecheck.ini

The following config is equivalent to licensecheck -u 'requirements:requirements.txt;requirements_optional.txt' -f json

[licensecheck]
using = "requirements:requirements.txt;requirements_optional.txt"
format = "json"

Documentation

See the Docs for more information.

Install With PIP

pip install licensecheck

Head to https://pypi.org/project/licensecheck/ for more info

Language information

Built for

This program has been written for Python versions 3.7 - 3.10 and has been tested with both 3.7 and 3.10

Install Python on Windows

Chocolatey

choco install python

Windows - Python.org

To install Python, go to https://www.python.org/downloads/windows/ and download the latest version.

Install Python on Linux

Apt

sudo apt install python3.x

Dnf

sudo dnf install python3.x

Install Python on MacOS

Homebrew

brew install python@3.x

MacOS - Python.org

To install Python, go to https://www.python.org/downloads/macos/ and download the latest version.

How to run

Windows

  • Module py -3.x -m [module] or [module] (if module installs a script)

  • File py -3.x [file] or ./[file]

Linux/ MacOS

  • Module python3.x -m [module] or [module] (if module installs a script)

  • File python3.x [file] or ./[file]

Download Project

Clone

Using The Command Line

  1. Press the Clone or download button in the top right
  2. Copy the URL (link)
  3. Open the command line and change directory to where you wish to clone to
  4. Type 'git clone' followed by URL in step 2
    git clone https://github.com/FHPythonUtils/LicenseCheck
    

More information can be found at https://help.github.com/en/articles/cloning-a-repository

Using GitHub Desktop

  1. Press the Clone or download button in the top right
  2. Click open in desktop
  3. Choose the path for where you want and click Clone

More information can be found at https://help.github.com/en/desktop/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop

Download Zip File

  1. Download this GitHub repository
  2. Extract the zip archive
  3. Copy/ move to the desired location

Community Files

Licence

MIT License Copyright (c) FredHappyface (See the LICENSE for more information.)

Changelog

See the Changelog for more information.

Code of Conduct

Online communities include people from many backgrounds. The Project contributors are committed to providing a friendly, safe and welcoming environment for all. Please see the Code of Conduct for more information.

Contributing

Contributions are welcome, please see the Contributing Guidelines for more information.

Security

Thank you for improving the security of the project, please see the Security Policy for more information.

Support

Thank you for using this project, I hope it is of use to you. Please be aware that those involved with the project often do so for fun along with other commitments (such as work, family, etc). Please see the Support Policy for more information.

Rationale

The rationale acts as a guide to various processes regarding projects such as the versioning scheme and the programming styles used. Please see the Rationale for more information.

Metadata

Release files for licensecheck 2022

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

Source distribution (sdist)

Source distribution for licensecheck 2022
File Size Uploaded
licensecheck-2022.tar.gz 17.5 kB Details

Built distribution (wheel)

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

Total release size: 34.4 kB

Release files / licensecheck-2022.tar.gz

Download URL licensecheck-2022.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a619c17dd850e4914e8e7e31edce6693248b7c0de4ebecd0f12e651655ceaef9
BLAKE2b-256 checksum
How to use checksums
b8fdf7c446a0bc4e2256615f7bca4aa566438589203c0ef3b2120fa600b4f2e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Windows/10

Release files / licensecheck-2022-py3-none-any.whl

Download URL licensecheck-2022-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69d78df5cb55c71c619519a52a2b2ad43b72c6b4d092d7d54e299f6933c9338e
BLAKE2b-256 checksum
How to use checksums
7e8108c3f1ef15e2839301f7719c6f78c7502b448599b2a0364188f2358739cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Windows/10

Release history Release notifications | RSS feed

2025

2 release files

2024.3

2 release files

2024.1

2 release files

2024

2 release files

2023.5

2 release files

2023.4

2 release files

2023.3

2 release files

2023.2

2 release files

2023

2 release files

2022.3

2 release files

2022.2

2 release files

This release

2022 This release

2 release files

2021.5

2 release files

2021.3

2 release files

2021.2

2 release files

2021

2 release files

2020

2 release files

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