Skip to content

ilastik/conda-3rdparty

Repository files navigation

Anaconda-Server Badge Code style: black

conda 3rd party

Extract/summarize all licenses in an environment

Installation

conda install -c ilastik-forge -c conda-forge conda-3rdparty

Usages

Command line usage:

# generate text file with all licenses, sorted by package name
conda 3rdparty -n <environment_name> > 3rdparty.txt

# check if all licenses are present
conda 3rdparty -n <environment_name> --check

supply missing licenses externally

conda 3rdparty -n <environment_name> --fallback-file <path-to-fallback.json>

# json file assumed to be a dictionary of
# dict["<package_name>"]["license_file"] = ["list_of_license", "files_relative_to_the_json_file"]

library usage

from conda3rdparty import render_license_info
from pathlib import Path

license_texts = render_license_info(env_name="myenvname")
# also takes `template_file: Path` and `fallback_file: Path` kwargs

jinja2 template support

A template for rendering can be supplied to the cli with --template.

Customization

All keys from conda-meta/<package>.json are available for rendering via elements the license_infos list. Each license_info has the additional '3rd_party_license_info' key, with the following keys:

  • license: name of the license
  • license_family: name of the license family
  • license_texts: list of license texts (some packages have multiple)
Template examples
basic template

This is also the default template if no template file is supplied to cli:

3rd-party licenses

{% for info in license_infos %}
License for {{ info['name'] }} {{ info['version'] }}
    {% for license_text in info['3rd_party_license_info']['license_texts'] %}
{{ license_text }}
{% endfor %}
{% endfor %}
Example of template for rendering to markdown

This is also the default template if no template file is supplied to cli:

# 3rd-party licenses

{% for info in license_infos %}
## {{ info['name'] }} {{ info['version'] }} {{ info['build'] }}
    {% for license_text in info['3rd_party_license_info']['license_texts'] %}
{{ license_text }}
{% endfor %}
{% endfor %}