Output the licenses used by dependencies and check if these are compatible with the project license
Project description
LicenseCheck
Output the licences used by dependencies and check if these are compatible with the project license
Table of Contents
- Examples from the command-line
- Help
- Configuration Example
- Documentation
- Install With PIP
- Language information
- Install Python on Windows
- Install Python on Linux
- Install Python on MacOS
- How to run
- Download Project
- Community Files
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
- Press the Clone or download button in the top right
- Copy the URL (link)
- Open the command line and change directory to where you wish to clone to
- 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
- Press the Clone or download button in the top right
- Click open in desktop
- 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
- Download this GitHub repository
- Extract the zip archive
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file licensecheck-2022.tar.gz
.
File metadata
- Download URL: licensecheck-2022.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a619c17dd850e4914e8e7e31edce6693248b7c0de4ebecd0f12e651655ceaef9 |
|
MD5 | e1bb66f3262470eb991c2cd962bb0211 |
|
BLAKE2b-256 | b8fdf7c446a0bc4e2256615f7bca4aa566438589203c0ef3b2120fa600b4f2e2 |
File details
Details for the file licensecheck-2022-py3-none-any.whl
.
File metadata
- Download URL: licensecheck-2022-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69d78df5cb55c71c619519a52a2b2ad43b72c6b4d092d7d54e299f6933c9338e |
|
MD5 | 6b3c11230dcff8cbbd34c2f127f1ab53 |
|
BLAKE2b-256 | 7e8108c3f1ef15e2839301f7719c6f78c7502b448599b2a0364188f2358739cf |