Skip to main content

lice

Lice generates license files. No more hunting down licenses from other projects.

Changes from the original 'Lice' project

This version fixes the compatibility issue with Python 3.12, and adds some new features:

  • It has an API that can be imported into your Python projects to allow you to generate licenses directly from within your own project.
  • Can read from a config file for default values.
  • Can optionally copy the license to the clipboard automatically.
  • Converted from 'argparse' to 'Typer' for CLI handling.
  • It now uses uv for dependency management.
  • Fixes the issue where extra spaces and newlines were added to the generated license text. This was considered a bug by at least several users, so it was fixed in version 0.10.0. However, if you want to generate a license with the old style, you can use the --legacy option or set the legacy key in the configuration file to true.
  • The code has been modernized and cleaned up, all type-hinting has been added.
  • It passes strict linting with the latest 'Ruff' and 'mypy'.
  • GitHub actions set up for linting, Renovate and Dependency Review.
  • Can output a list of licenses and languages in JSON format for integration with other tools.

In addition, future plans can be seen in the TODO.md file.

Installation

Installation is standard. If you are using pipx (recommended) install it as:

pipx install lice3

Otherwise use pip as standard:

pip install lice3

Development Version

If you want to install the development version to try out new features before they are release, you can do so with the following command:

pipx install git+https://github.com/Khabib73/lice3.git

or

pip install git+https://github.com/Khabib73/lice3.git

Autocompletion

To enable autocompletion for lice options, run the following command after installation:

lice --install-completion

Overview

Full usage information is available on the documentation site at https://khabib73.github.io/lice3

Generate a BSD-3 license, the default:

$ lice
Copyright (c) 2013, Jeremy Carbaugh

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
...

Generate an MIT license:

$ lice mit
The MIT License (MIT)
Copyright (c) 2013 Jeremy Carbaugh

Permission is hereby granted, free of charge, to any person obtaining a copy
...

Generate a BSD-3 license, specifying the year and organization to be used:

$ lice -y 2012 -o "Sunlight Foundation"
Copyright (c) 2012, Sunlight Foundation

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
...

Generate a BSD-3 license, formatted for python source file:

$ lice -l py

# Copyright (c) 2012, Sunlight Foundation
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
...

Generate a python source file with a BSD-3 license commented in the header:

$ lice -l py -f test
$ ls
test.py
$ cat test.py

# Copyright (c) 2012, Sunlight Foundation
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
...

Generate a source file (language detected by -f extension):

$ lice -f test.c && cat test.c
/*
 * Copyright (c) 2012, Sunlight Foundation
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 ...

If organization is not specified, lice will first attempt to use git config to find your name. If not found, it will use the value of the $USER environment variable. If the project name is not specified, the name of the current directory is used. Year will default to the current year.

You can see what variables are available to you for any of the licenses:

$ lice --vars mit
The mit license template contains the following variables:
  year
  organization

I want XXXXXXXXX license in here!

Great! Is it a license that is commonly used? If so, open an issue or, if you are feeling generous, fork and submit a pull request.

Usage

You can get help on the command line with lice --help:

$ lice --help

 Usage: lice [OPTIONS] [license]

 Generates a license template with context variables, and can optionally write this to a file.

╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────╮
│   license_name      [license]  The license to generate, one of: afl3, agpl3, apache, bsd2, bsd3,  │
│                                cc0, cc_by, cc_by_nc, cc_by_nc_nd, cc_by_nc_sa, cc_by_nd,          │
│                                cc_by_sa, cddl, epl, gpl2, gpl3, isc, lgpl, mit, mpl, wtfpl, zlib  │
│                                [default: bsd3]                                                    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────╮
│ --header                            Generate source file header for specified license             │
│ --org                 -o      TEXT  Organization, defaults to .gitconfig or os.environ["USER"]    │
│                                     [default: <as above>]                                         │
│ --proj                -p      TEXT  Name of project, defaults to name of current directory        │
│                                     [default: <current folder>]                                   │
│ --template            -t      TEXT  Path to license template file [default: None]                 │
│ --year                -y      TEXT  Copyright year [default: <current year>]                      │
│ --language            -l      TEXT  Format output for language source file, one of: agda, c, cc,  │
│                                     clj, cpp, css, el, erl, f, f90, h, hpp, hs, html, idr, java,  │
│                                     js, lisp, lua, m, ml, php, pl, py, ps, rb, scm, sh, txt, rs   │
│                                     [default: txt]                                                │
│ --file                -f      TEXT  Name of the output source file (with -l, extension can be     │
│                                     ommitted)                                                     │
│                                     [default: stdout]                                             │
| --clipboard           -c            Copy the generated license to the clipboard                   |
│ --vars                              List template variables for specified license                 │
│ --licenses                          List available license templates and their parameters         │
│ --languages                         List available source code formatting languages               │
│ --install-completion                Install completion for the current shell.                     │
│ --show-completion                   Show completion for the current shell, to copy it or          │
│                                     customize the installation.                                   │
│ --help                -h            Show this message and exit.                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯

Config File

The app will look for a config file in ~/.config/lice/config.toml. This file can be used to set default values for the license and organization. See the documentation website for more information.

[lice]
default_license = "mit"
organization = "Grant Ramsay"
clipboard = false
legacy = false

The 'default_license' is checked at run-time, and if it is not valid then it falls back to the BSD-3 license.

Integrate into your projects

Lice now includes an API that can be imported into your Python projects! This allows you to generate licenses from within your project. Here is an example:

from lice3.api import Lice

lice = Lice(organization="Awesome Organization", project="Awesome Project")
license_text = lice.get_license("mit")
print(license_text)

There are a few other methods available in the API, see the documentation for more information.

Integration with other tools

This tool can output a list of availailable licenses and languages in JSON format. This can be used to integrate with other non-Python tools. For example, to get a list of licenses in JSON format:

lice --metadata

The output will have 4 keys: licenses, languages, organization and project which another tool can use to populate a list of licenses and languages in a GUI for example. The first two keys are simple lists of strings that can be parsed.

For more fine-grained control, you can use the API above (but only in Python)

Contribute to the Development

If you want to help with development of this project or just hack on the code, you can clone the repository and install the development dependencies with the following command:

uv sync

We use uv to manage the virtual environment and dependencies. See Contributing and the relevant section on the website for details

All contributions are welcome, and I will try to respond to issues and PR's as soon as possible.

Changelog

See the CHANGELOG.md file for details for this fork, and the OLD_CHANGELOG.md file for the original project.

Metadata

Release files for lice3 0.14.0

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

Source distribution (sdist)

Source distribution for lice3 0.14.0
File Size Uploaded Provenance Actions
lice3-0.14.0.tar.gz 267.9 kB With provenance Details for lice3-0.14.0.tar.gz

Built distribution (wheel)

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

Total release size: 417.7 kB

Release files / lice3-0.14.0.tar.gz

Download URL lice3-0.14.0.tar.gz
Size 267.9 kB
Tags Source
SHA-256 checksum
How to use checksums
21998d0d321cd15e29060e2b21afac6aa29209e272ca68be172249e015e14d85
BLAKE2b-256 checksum
How to use checksums
05fd5b8cae200863f670b787020be49ba896bb936a4ff0e021f0a6eb76c40419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / lice3-0.14.0-py3-none-any.whl

Download URL lice3-0.14.0-py3-none-any.whl
Size 149.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dac2c20a8049a83d19ec0d0ee14f0eb85516a43692143f46fbda6b44b74e2d05
BLAKE2b-256 checksum
How to use checksums
1642e20425884c97bd0046e695e8613e2c00579831dc97ad8ba134747981d628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for lice3 0.14.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lice3-0.14.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

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.14.0 This release

2 release files Full 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