Skip to main content

A Rust CLI packaged for Python project dependency license check and license header formatting.

Project description

licensepy

Python Depedency License Check and License Header Formating.

licensepy is a Python dependency license check and license header check/format library written in Rust. This package has recursive dependency checks that are not offered by many existing license check libraries. By default, the output will group packages by their licenses.

Configure the tool with a pyproject.toml file at the root directory of the project with a list of licenses to avoid. If dependencies of the project are found to use these flagged licenses, licensepy will exit with the count of these projects. Otherwise, it will exit with code 0. For the license header formatter, the exit code will be the count of the source code files with incorrect header.

Installing

Use pip to install licensepy in your project.

$ pip3 install licensepy

Command Line Arguments

Dependency license check

For the dependency license check, the following are the command line arguments.

$ licensepy check
  1. -r, --recursive: Recursively find all the dependencies of the project and their licences.
    • Recursive dependencies will have the color red if they have licenses that have been flagged to avoid and green otherwise.
  2. -by-package: Group output by packages in alphabetical order.
  3. -s, silent: Silence all outputs.
  4. -f, print-fails: Only print the packages whose licenses are flagged to be avoided.
  5. -j, --num-threads: Number of threads to use. Default is 1. Max is 32 [default: 1].

License header checker and formatter

For the license

$ licensepy format
  1. files: Positional arguments are the Python files to run license header checker/formatter.
  2. -l, --licensee: Licensee. Has precedence over value from config.
  3. -y, --license-year: License year. Has precedence over value from config.
  4. -s, --silent: Don't print any outputs. Default if false.
  5. -d, --dry-run: Don't run formatter. Only print outputs. Default if false.
  6. -j, --num-threads: Number of threads to use. Default is 1. Max is 32 [default: 1].

Configuration

Licenses can be flagged to avoid in a pyproject.toml files saved in the root of the project directory. Licenses should be stored in a list.

# In the pyproject.toml file

[tool.licensepy]
# List of licenses to avoid.
avoid = ["MIT"]

# header template: The template for the license header. {year}, {licensee}
# are placeholders that will be populated with values from command line
# or the config. The template can have the # at the beginning or not.
license_header_template = "# Copyright {year} {licensee}"

# license_year: The value to replace the {year} in the license_header_template.
# Default value is the current year.
license_year = 2025

# licensee: The value to replace the {licensee} in the license_header_template.
# If the {licensee} placeholder is found in the template and the licensee field
# or the command line argument are
licensee = "Nati"

This is the output when the above configuration is used for:

$ licensepy check

$ licensepy check --by-package

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

licensepy-1.1.1.tar.gz (397.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

licensepy-1.1.1-cp312-cp312-manylinux_2_39_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

File details

Details for the file licensepy-1.1.1.tar.gz.

File metadata

  • Download URL: licensepy-1.1.1.tar.gz
  • Upload date:
  • Size: 397.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.3

File hashes

Hashes for licensepy-1.1.1.tar.gz
Algorithm Hash digest
SHA256 d403e7db4c6c96b34353662e913fe88ae2a757c41f341f8cae8b587610c783ab
MD5 f692d0df09f7f91f4de56dde4f63fad3
BLAKE2b-256 f73612764f5f07c56a0d46343fc7421f23662bb15148b1fabf02d1c1341d6e5e

See more details on using hashes here.

File details

Details for the file licensepy-1.1.1-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for licensepy-1.1.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 7fb4a17a087a2fe8ee92a6ca0d6b69aa7fc0893c81584ccdd112ce936aa6f752
MD5 3d45369510e9c51c6144bcdd39a92e15
BLAKE2b-256 761e6c13157f0d6b475071a0ab633cf5df3d6dcf065fb4ee0243465091104810

See more details on using hashes here.

Supported by

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