Skip to main content

PyLicenses

Find license types and texts for all installed packages in conda and pip environments, producing a distribution-ready file THIRDPARTY-LICENSES with required details on all packages, including their respective license texts.

Why yet another tool?

There are several packages with similar intents, however I did not find any to match the particular usecase PyLicenses covers. Specifically to produce a complete set of licenses for all installed packages, at the package level (as opposed to the file level as many other such tools do).Also I wanted to have a focused tool that is easily extensible to any framework, in any language.

Features

PyLicense

  • produces the THIRDPARTY-LICENSES file as a report on all packages

  • collects data from conda, pip, pypi and github to retrieve information on authorship, package homepage, license style and - most importantly - the actual license text.

  • uses a pipeline of scanners/data collectors. Adding a new framework to scan (e.g. to include npm modules) is a matter of writing a new PackageProvider class with a single method.

  • produces reports and statistics on primary packages (direct dependency) and secondary packages (pulled-in through a dependency), notably this works across conda and pip. Statistics currently include counts per license type.

  • highlights packages were the license information or license text is missing

  • can map packages to a fixed license URL for packages that do not include the license text or where the LICENSE file is difficult to find by automated means.

How to use

Within your conda or pip virtualenv, run

$ python -m pylicense

To see options

$ python -m pylicense -h usage: __main__.py [-h] [–github GITHUB] [–stats STATS]

optional arguments:
-h, --help

show this help message and exit

--github GITHUB

specify github user,password

--stats STATS

print statistics

Sample output

See the THIRDPARTY-LICENSES file in this repository for the full license collection report of this package.

The direct output looks something like this

$ python -m pylicense Packages directly required:

name author license ———- ————————– ———————– pylicenses Patrick Senti Apache 2.0 wheel Daniel Holth Other urllib3 Andrey Petrov MIT tabulate Sergey Astanin MIT sh Andrew Moffat MIT setuptools Python Packaging Authority MIT License requests Kenneth Reitz Apache Software License pip The pip developers MIT certifi Kenneth Reitz MPL-2.0 libedit NetBSD python PSF

Packages pulled in through other requirements:

name author license ————— —————- ————————————– idna Kim Davies BSD Like chardet Daniel Blanchard GNU Lesser General Public License v2.1 ca-certificates ISC libffi MIT libgcc-ng GPL libstdcxx-ng GPL3 with runtime exception ncurses Free software - X11 License openssl OpenSSL readline GPL3 sqlite Public-Domain xz Public-Domain, GPL zlib zlib

SUCCESS Good news. There are no packages without license texts

SUCCESS The full license report is available in THIRDPARTY-LICENSES

How to implement a new scanner

  1. Add a class in pylicenses.provider, e.g.

    class MyPackageScanner(PackageProvider):
    def get_packages_info(self, packages, subset=None)

    … your code to update packages … return packages

    packages is a dictionary mapping name=>data, where name is either the package’s canonical name or the full distribution name (name-version-type), and data is the data collected so far. For programming convenience all mapping of the same package, independent of the key, reference the same data object.

    Currently there are only very few conventions for the contents of data:

    • name is the name of package without version or distribution type

    • dist_name is the full distribution name (name-version or name-version-type)

    • license is the canonical license name (e.g. MIT, Apache-2.0 etc.)

    • license_text is the actual license text

    • license_source is the filename/URL to the source of the license text

    • license_trace is the last scanner to update the data

    Any other data can be stored by the scanners as they see fit. Note the dependency on PackageProvider as a base class is a convenience only.

  2. Add the new scanner class to PyLicenses.PROVIDERS

  3. Add unit tests

License

MIT License - Copyright (c) 2018 Patrick Senti, productaize.io See LICENSE file

Metadata

Release files for pylicenses 0.1

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

Source distribution (sdist)

Source distribution for pylicenses 0.1
File Size Uploaded Provenance Actions
pylicenses-0.1.tar.gz 12.3 kB Without provenance Details for pylicenses-0.1.tar.gz

Built distribution (wheel)

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

Total release size: 26.8 kB

Release files / pylicenses-0.1.tar.gz

Download URL pylicenses-0.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
13e8c13b3edbc88040410bc79c35032da1bf835053836e56fe450dd40f52a9ac
BLAKE2b-256 checksum
How to use checksums
d6c48bf60bb12c9d94fda12c34513d14f3d2f02b960b52b2e0ef045919ece11a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / pylicenses-0.1-py3-none-any.whl

Download URL pylicenses-0.1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90342aa36afdeeb573a12f6148f283d051643d672e4d329f20669e6f26fab3dd
BLAKE2b-256 checksum
How to use checksums
5789a77f1cccd48c446bd8de3b532de332bef285b43bc3b2df785993f4c24f29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Security for pylicenses 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

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