Skip to main content

Pytest plugin reporting dependency licenses

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tests_pylicense


Overview

swarmauri_tests_pylicense is a pytest plugin that scans a package's full dependency tree and ensures each dependency declares a license. The plugin resolves dependencies recursively, checking every transitive requirement. It inspects both the License metadata field and any Classifier entries that declare a license.

By default, the plugin runs in parameterized mode which creates one test per dependency. An aggregate mode is also available that reports all missing licenses in a single test.

Installation

pip install swarmauri_tests_pylicense

pytest automatically discovers the plugin once it is installed.

Usage

Parameterized (default)

Run pytest with the package name to scan its dependency licenses:

pytest --pylicense-package=<your-package>

Each generated test encodes the full dependency path, the resolved version, and the detected license of the terminal package. For example:

swarmauri_tests_pylicense:license::pkg::depA::depB==1.2.3 [Apache-2.0]

Aggregate

Use the --pylicense-mode=aggregate flag to consolidate checks into one test:

pytest --pylicense-package=<your-package> --pylicense-mode=aggregate

Allow and Disallow Lists

To restrict acceptable licenses, provide a comma-separated allow list or disallow list. These can be passed via command-line options or environment variables.

Command-line:

pytest --pylicense-package=<your-package> --pylicense-allow-list=MIT,Apache-2.0
pytest --pylicense-package=<your-package> --pylicense-disallow-list=GPL

Environment variables:

export PYLICENSE_ALLOW_LIST="MIT,Apache-2.0"
export PYLICENSE_DISALLOW_LIST="GPL"
pytest --pylicense-package=<your-package>

If both are provided, any license not in the allow list or explicitly present in the disallow list will cause a test failure. By default, all licenses are allowed and none are disallowed.

Accepting Specific Dependencies

Some transitive dependencies may ship with unusual or proprietary licenses that are acceptable for your project. Use --pylicense-accept-deps (or the PYLICENSE_ACCEPT_DEPS environment variable) with a comma-separated list to explicitly bypass those packages. For example:

pytest --pylicense-package=<your-package> --pylicense-accept-deps=cffi

This tells the plugin to treat cffi as pre-approved. Any license issues for cffi—including unknown or non-standard licenses—are ignored while other dependencies continue to be validated normally.

License

Licensed under the Apache 2.0 License.

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

swarmauri_tests_pylicense-0.1.2.dev4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_tests_pylicense-0.1.2.dev4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_tests_pylicense-0.1.2.dev4.tar.gz.

File metadata

  • Download URL: swarmauri_tests_pylicense-0.1.2.dev4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tests_pylicense-0.1.2.dev4.tar.gz
Algorithm Hash digest
SHA256 3a794edb7ecbf7b3e4dcdc7456504a93f1c55cd2aaf81a338c83e7a959e0be7f
MD5 155e9df09e22f8ee4e652007878d6a50
BLAKE2b-256 bfb7df0c948802311b18600d5da707a511b12f348d173ebf6e2441dd450af37a

See more details on using hashes here.

File details

Details for the file swarmauri_tests_pylicense-0.1.2.dev4-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tests_pylicense-0.1.2.dev4-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tests_pylicense-0.1.2.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 8a4f448b5c1939e2f5fc586e8b54fcdbefb4ca446f550b3af60146670810cfb3
MD5 228630c254feaae3b953b8512547734b
BLAKE2b-256 b67f601dd37032a64a7fbe5d3b9c0df94a1cf03787cc035d45326fa4bcaed804

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