SPDX Model Python Bindings
Maintained. Last release 5 months ago, commits in 4 of the last 26 weeks. Weaker on commit activity.
pip install spdx-python-modelspdx-python-model
spdx-python-model is a Python library for working with the SPDX 3 data model.
Read the API documentation.
All bindings in this repository are auto-generated from the RDF and SHACL definitions of the SPDX specification version 3 using shacl2code during the package build process.
NOTE: The bindings are pretty low level, intended for more directly manipulating SPDX files. While they are fully functions, they lack higher level helper functions that may be useful for creating SPDX documents. If you want a higher level approach, please see the SPDX Python Tools (however, it doesn't yet support SPDX 3).
Installation
Install from PyPI
python3 -m pip install spdx-python-model
Install from Git
If you would like to pull the bindings directly from Git instead of using a released version from PyPI, the following command can be used:
python3 -m pip install git+https://github.com/spdx/spdx-python-model.git@main
Note that this will pull the latest version from the main branch. If you want
a specific commit, replace main with the git commit SHA.
Install/build using local SPDX model files
Using local SPDX model files is ideal for testing pre-release versions or when official URLs are not yet live.
It is also required for build systems that prohibit network access during packaging, such as Debian or Yocto.
To build using local model files:
-
Clone the repository:
git clone https://github.com/spdx/spdx-python-model.git cd spdx-python-model -
Download model files:
Run the following commands to download the necessary files for a specific SPDX version and keep it in a local directory:
mkdir -p ~/spdx_models/v3.0.1 cd ~/spdx_models/v3.0.1 wget https://spdx.org/rdf/3.0.1/spdx-context.jsonld wget https://spdx.org/rdf/3.0.1/spdx-json-serialize-annotations.ttl wget https://spdx.org/rdf/3.0.1/spdx-model.ttl