All Projects → dhatim → python-license-check

dhatim / python-license-check

Licence: Apache-2.0 license
Check python packages from requirement.txt and report issues

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-license-check

AMChoice
Radio Button and check box for iOS
Stars: ✭ 45 (-59.46%)
Mutual labels:  check
license-ls
Get a list of licenses used by a projects dependencies
Stars: ✭ 17 (-84.68%)
Mutual labels:  license
nagitheus
Nagios Check towards Prometheus
Stars: ✭ 19 (-82.88%)
Mutual labels:  check
datatyping
Pythonic type checking
Stars: ✭ 37 (-66.67%)
Mutual labels:  check
private-ip
Check if IP address is private.
Stars: ✭ 26 (-76.58%)
Mutual labels:  check
checkif.js
Javascript check library
Stars: ✭ 30 (-72.97%)
Mutual labels:  check
python-valid8
Yet another validation lib ;). Provides tools for general-purpose variable validation, function inputs/outputs validation as well as class fields validation. All entry points raise consistent ValidationError including all contextual details, with dynamic inheritance of ValueError/TypeError as appropriate.
Stars: ✭ 24 (-78.38%)
Mutual labels:  check
can-npm-publish
A command line tool that check to see if `npm publish` is possible.
Stars: ✭ 61 (-45.05%)
Mutual labels:  check
SimpleLicensing
A Go Based Licensing System for Digital Rights Management
Stars: ✭ 96 (-13.51%)
Mutual labels:  license
scancode.io
ScanCode.io is a server to script and automate software composition analysis pipelines with ScanPipe pipelines. This project is sponsored by NLnet project https://nlnet.nl/project/vulnerabilitydatabase/ Google Summer of Code, nexB and others generous sponsors!
Stars: ✭ 66 (-40.54%)
Mutual labels:  license
react-native-appstore-version-checker
[Deprecated] A react native module to fetch the version of latest app from android playstore or apple app store
Stars: ✭ 88 (-20.72%)
Mutual labels:  check
url-survival-check
批量检测URL存活
Stars: ✭ 44 (-60.36%)
Mutual labels:  check
sandia-public-license
This is not a license of honor. No highly esteemed copyright statement is written here.
Stars: ✭ 114 (+2.7%)
Mutual labels:  license
danetls
Program to test DANE enabled TLS Services
Stars: ✭ 18 (-83.78%)
Mutual labels:  check
diffido
Watch web pages for changes
Stars: ✭ 19 (-82.88%)
Mutual labels:  check
connection checker
Android library for checking the internet connectivity of a device.
Stars: ✭ 26 (-76.58%)
Mutual labels:  check
has-value
Returns true if a value exists, false if empty. Works with deeply nested values using object paths.
Stars: ✭ 27 (-75.68%)
Mutual labels:  check
TrialLicensing
Swift framework to deal with licensing and time-based trial periods in macOS apps.
Stars: ✭ 36 (-67.57%)
Mutual labels:  license
shallow-equal-object
Shallow equal check object that support TypeScript.
Stars: ✭ 21 (-81.08%)
Mutual labels:  check
friends-and-lovers-license
what if code i wrote was only for the people i love?
Stars: ✭ 61 (-45.05%)
Mutual labels:  license

Python License Checker

Check python packages listed in a requirements.txt file and report license issues.

About

You can define a list of authorized licenses, unauthorized licenses and authorized packages.

The tool will check the requirements.txt file, check packages and their dependencies and return an error if some packages are not compliant against the given strategy.

The tool has 3 levels of checks to select from:

Standard (default):
A package is considered as compliant when at least one of its licenses is in the authorized license list, or if the package is in the list of authorized packages.
Cautious:
Same as Standard, but a package is not considered compliant when one or more of its licenses is in the unauthorized license list, even if it also has a license in the authorized license list. A package is still compliant if present in the authorized packages list.
Paranoid:
All licenses listed for a package must be in the authorised license list for the package to be considered compliant. A package is still compliant if present in the authorized packages list.

Assumption

The tool requires to be installed in the same python (virtual) environment as the packages. This, because it uses pkg_resources to access the packages resources and thus, their licenses information.

How to install

$ pip install liccheck

How to use

liccheck will read the requirements.txt and verify compliance of packages against a strategy defined in the ini file. If the requirements file is not specified on the command line, it will search for requirements.txt in the current folder. You have to setup an ini file with an authorized license list, unauthorized license list and authorized package list. The packages from your requirements.txt need to all be installed in the same python environment/virtualenv as liccheck. If the ini file is not specified on the command line, it will search for liccheck.ini in the current folder.

Here is an example of a liccheck.ini file:

# Authorized and unauthorized licenses in LOWER CASE
[Licenses]
authorized_licenses:
        bsd
        new bsd
        bsd license
        new bsd license
        simplified bsd
        apache
        apache 2.0
        apache software license
        gnu lgpl
        lgpl with exceptions or zpl
        isc license
        isc license (iscl)
        mit
        mit license
        python software foundation license
        zpl 2.1

unauthorized_licenses:
        gpl v3

[Authorized Packages]
# Python software license (see http://zesty.ca/python/uuid.README.txt)
uuid: 1.30

Note: versions of authorized packages can be defined using PEP-0440 version specifiers, such as >=1.3,<1.4. The implementation uses the nice package semantic_version.

For demo purpose, let's say your requirements.txt file contains this:

Flask>=0.12.1
flask_restful
jsonify
psycopg2>=2.7.1
nose
scipy
scikit-learn
pandas
numpy
argparse
uuid
sqlbuilder
proboscis
pyyaml>=3.12

The execution will output this:

$ liccheck -s my_strategy.ini -r my_project/required.txt
gathering licenses...23 packages and dependencies.
check forbidden packages based on licenses...none
check authorized packages based on licenses...19 packages.
check authorized packages...4 packages.
check unknown licenses...none

If some dependencies are unknown or are not matching the strategy, the output will be something like:

$ liccheck -s my_strategy.ini -r my_project/requirements.txt
    gathering licenses...32 packages and dependencies.
    check forbidden packages based on licenses...1 forbidden packages :
        Unidecode (0.4.21) : GPL ['GNU General Public License v2 or later (GPLv2+)']
          dependency:
              Unidecode << python-slugify << yoyo-migrations

    check authorized packages based on licenses...24 packages.
    check authorized packages...6 packages.
    check unknown licenses...1 unknown packages :
        feedparser (5.2.1) : UNKNOWN []
          dependency:
              feedparser

Also supports pyproject.toml like:

[project]
dependencies = [
    "Flask>=0.12.1",
    "flask_restful",
    "jsonify",
    "psycopg2>=2.7.1",
    "nose",
    "scipy",
    "scikit-learn",
    "pandas",
    "numpy",
    "argparse",
    "uuid",
    "sqlbuilder",
    "proboscis",
    "pyyaml>=3.12",
]

[project.optional-dependencies]
test = [
    "pytest>=3.6.3",
]

[tool.liccheck]
authorized_licenses = [
    "bsd",
    "new bsd",
    "bsd license",
    "new bsd license",
    "simplified bsd",
    "apache",
    "apache 2.0",
    "apache software license",
    "gnu lgpl",
    "lgpl with exceptions or zpl",
    "isc license",
    "isc license (iscl)",
    "mit",
    "mit license",
    "python software foundation license",
    "zpl 2.1",
]
unauthorized_licenses = [
    "gpl v3",
]
# strategy_ini_file = "./liccheck.ini"
# level = "STANDARD"
# requirement_txt_file = "./requirements.txt" # ignored if dependencies or optional_dependencies are defined
# reporting_txt_file = "path/to/reporting.txt file" # by default is None
# no_deps = false
dependencies = true # to load [project.dependencies]
optional_dependencies = ["test"] # to load extras from [project.optional-dependencies]

[tool.liccheck.authorized_packages]
uuid = "1.30"

By default, exact matching is required between each package's license and one of the license of the authorized or unauthorized list. You can also provide regular expressions to match licenses by using the as_regex boolean flag. For instance, to exclude GPL licenses, one could define the following configuration in pyproject.toml:

...

unauthorized_licenses = [
    '\bgpl'
]
as_regex = true

Using liccheck with pre-commit

Add this to your .pre-commit-config.yaml:

- repo: https://github.com/dhatim/python-license-check
  rev: master
  hooks:
  - id: liccheck
    language: system

Contributing

To run the tests:

$ tox -p all

Licensing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].