Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A simple tool/library for working with SPDX license definitions.

Project description

spdx_license_list

A simple tool/library for working with SPDX license definitions.

The sole purpose of this module is to make SPDX definitions available in python. Thus eliminating the chore of handling SPDX definitions and parsing them.

This is not a SPDX specification implementation. If you're looking for and actually standard conform implementation consult: https://spdx.org/tools

Tests and Checks

SPDX definitions up to date? SPDX definitions up to date?
unit tests and code checks okay? unit tests and code checks okay?

Installation

The easiest way to get spdx_license_list is installing it using pip:

python3 -m pip install spdx-license-list

API

This library mostly comes with SPDX data as python dictionaries. All data is accessible as items for our main module

import spdx_license_list

API for working with licenses

All license registered with SPDX are available as a huge dictionary. This is where it's located:

spdx_license_list.LICENSES

This dictionary uses SPDX-license IDs as key and the value is again a dictionary containing following items. Currently only this subset of values is available:

  • isDeprecatedLicenseId - bool value telling you whether this license definition is oudated or not.
  • isFsfLibre - bool value telling you whether this license is "free software" by the definition of FSF.
  • isOsiApproved - bool value telling you whether this license is "open source" by the definition of OSI.
  • licenseId - the SPDX license ID
  • name - the full name of this license
  • referenceNumber - a integer id unique for this license

API examples

Get a names of licenses approved by FSF:

[x['licenseId'] for x in spdx_license_list.LICENSES.values() if x['isFsfLibre']]

Get all reference numbers of non deprecated license entries:

[x['referenceNumber'] for x in spdx_license_list.LICENSES.values() if not x['isDeprecatedLicenseId']]

Get all license IDs:

spdx_license_list.LICENSES.values.keys()

Get reference number for each known license ID:

{k: v['referenceNumber'] for k, v in spdx_license_list.LICENSES.items()}

CLI tool

We've also included a CLI tool to do some simple operations. Try the help option (-h) for getting more infos.

CLI examples

Install on Debian/Ubuntu and get the list of standardized licenses approved either by FSF or OSI:

sudo apt install python3-pip
python3 -m pip install spdx-license-list
python3 -m spdx_license_list --filter-fsf-or-osi

Print a list containing all SPDX standardized licneses approved by both FSF and OSI:

python3 -m spdx_license_list print --filter-fsf --filter-osi

Check if this version on spdx_license_list sill is up to date, or if there's a newer release of SPDX license definitions available.

python3 -m spdx_license_list check-version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for spdx-license-list, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size spdx_license_list-0.3.0-py3-none-any.whl (14.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size spdx_license_list-0.3.0.tar.gz (14.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page