Skip to main content

reuse is a tool for compliance with the REUSE recommendations.

Project description

reuse

The latest version of reuse can be found on PyPI. Information on what versions of Python reuse supports can be found on PyPI. REUSE status readme style standard Packaging status

reuse is a tool for compliance with the REUSE recommendations.

Background

Copyright and licensing is difficult, especially when reusing software from different projects that are released under various different licenses. REUSE was started by the Free Software Foundation Europe (FSFE) to provide a set of recommendations to make licensing your Free Software projects easier. Not only do these recommendations make it easier for you to declare the licenses under which your works are released, but they also make it easier for a computer to understand how your project is licensed.

As a short summary, the recommendations are threefold:

  1. Choose and provide licenses
  2. Add copyright and licensing information to each file
  3. Confirm REUSE compliance

You are recommended to read our tutorial for a step-by-step guide through these three steps. The FAQ covers basic questions about licensing, copyright, and more complex use cases. Advanced users and integrators will find the full specification helpful.

This tool exists to facilitate the developer in complying with the above recommendations.

There are other tools that have a lot more features and functionality surrounding the analysis and inspection of copyright and licenses in software projects. The REUSE helper tool, on the other hand, is solely designed to be a simple tool to assist in compliance with the REUSE recommendations.

Example demo

In this screencast, we are going to follow the tutorial, making the REUSE example repository compliant.

Demo of some basic REUSE tool commands

Install

Installation via package managers (Recommended)

There are packages available for easy install on some operating systems. You are welcome to help us package this tool for more distributions!

An automatically generated list can be found at repology.org, without any guarantee for completeness.

Install and run via pipx (Recommended)

The following one-liner both installs and runs this tool from PyPI via pipx:

pipx run reuse lint

pipx automatically isolates reuse into its own Python virtualenv, which means that it won't interfere with other Python packages, and other Python packages won't interfere with it.

If you want to be able to use reuse without prepending it with pipx run every time, install it globally like so:

pipx install reuse

reuse will then be available in ~/.local/bin, which must be added to your $PATH.

Installation via pip

To install reuse, you need to have the following pieces of software on your computer:

  • Python 3.6+
  • pip

You then only need to run the following command:

pip3 install --user reuse

After this, make sure that ~/.local/bin is in your $PATH. On Windows, the required path for your environment may look like %USERPROFILE%\AppData\Roaming\Python\Python39\Scripts, depending on the Python version you have installed.

To update reuse, run this command:

pip3 install --user --upgrade reuse

For full functionality, the following pieces of software are recommended:

  • Git
  • Mercurial 4.3+

Installation from source

You can also install this tool from the source code, but we recommend the methods above for easier and more stable updates. Please make sure the requirements for the installation via pip are present on your machine.

pip install .

Usage

First, read the REUSE tutorial. In a nutshell:

  1. Put your licenses in the LICENSES/ directory.
  2. Add a comment header to each file that says SPDX-License-Identifier: GPL-3.0-or-later, and SPDX-FileCopyrightText: $YEAR $NAME. You can be flexible with the format, just make sure that the line starts with SPDX-FileCopyrightText:.
  3. Verify your work using this tool.

Example of header:

# SPDX-FileCopyrightText: 2017 Free Software Foundation Europe e.V. <https://fsfe.org>
#
# SPDX-License-Identifier: CC-BY-SA-4.0

To check against the recommendations, use reuse lint:

~/Projects/reuse-tool $ reuse lint
[...]

Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)

This tool can do various more things, detailed in the documentation. Here a short summary:

  • annotate --- Add copyright and/or licensing information to the header of a file.

  • download --- Download the specified license into the LICENSES/ directory.

  • init --- Set up the project for REUSE compliance.

  • lint --- Verify the project for REUSE compliance.

  • spdx --- Generate an SPDX Document of all files in the project.

  • supported-licenses --- Prints all licenses supported by REUSE.

Run in Docker

The fsfe/reuse Docker image is available on Docker Hub. With it, you can easily include REUSE in CI/CD processes. This way, you can check for REUSE compliance for each build. In our resources for developers you can learn how to integrate the REUSE tool in Drone, Travis, GitHub, or GitLab CI.

You can run the helper tool simply by providing the command you want to run (e.g., lint, spdx). The image's working directory is /data by default. So if you want to lint a project that is in your current working directory, you can mount it on the container's /data directory, and tell the tool to lint. That looks a little like this:

docker run --rm --volume $(pwd):/data fsfe/reuse lint

You can also provide additional arguments, like so:

docker run --rm --volume $(pwd):/data fsfe/reuse --include-submodules spdx -o out.spdx

There are a number of tags available:

  • latest is the most recent stable release.
  • dev follows the main branch of this repository. Up-to-date, but potentially unstable.
  • latest-extra has a few extra packages installed, currently openssh-client.
  • latest-debian is based on python:slim. It is larger, but may be better suited for license compliance.

Run as pre-commit hook

You can automatically run reuse lint on every commit as a pre-commit hook for Git. This uses pre-commit. Once you have it installed, add this to the .pre-commit-config.yaml in your repository:

repos:
  - repo: https://github.com/fsfe/reuse-tool
    rev: v1.1.0
    hooks:
      - id: reuse

Then run pre-commit install. Now, every time you commit, reuse lint is run in the background, and will prevent your commit from going through if there was an error.

Maintainers

Contribute

Any pull requests or suggestions are welcome at https://github.com/fsfe/reuse-tool or via e-mail to one of the maintainers. General inquiries can be sent to reuse@lists.fsfe.org.

Interaction within this project is covered by the FSFE's Code of Conduct.

Starting local development is very simple, just execute the following commands:

git clone git@github.com:fsfe/reuse-tool.git
cd reuse-tool/
poetry install  # You may need to install poetry using your package manager.
poetry run pre-commit install  # Using poetry is optional here if you already have pre-commit.

Next, you'll find the following commands handy:

  • poetry run reuse
  • poetry run pytest
  • poetry run pylint src
  • make docs

License

This work is licensed under multiple licences. Because keeping this section up-to-date is challenging, here is a brief summary as of April 2020:

  • All original source code is licensed under GPL-3.0-or-later.
  • All documentation is licensed under CC-BY-SA-4.0.
  • Some configuration and data files are licensed under CC0-1.0.
  • Some code borrowed from spdx/tool-python is licensed under Apache-2.0.

For more accurate information, check the individual files.

Project details


Download files

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

Source Distribution

reuse-1.1.0.tar.gz (217.0 kB view details)

Uploaded Source

Built Distribution

reuse-1.1.0-cp311-cp311-manylinux_2_36_x86_64.whl (180.1 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.36+ x86-64

File details

Details for the file reuse-1.1.0.tar.gz.

File metadata

  • Download URL: reuse-1.1.0.tar.gz
  • Upload date:
  • Size: 217.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.11.0 Linux/6.0.9-300.fc37.x86_64

File hashes

Hashes for reuse-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7a054f6e372ad02d0b1b07368030fc38746b50ed45f5422a81994e7a88b52f1f
MD5 efef219dedc0a2e5c465d4cd6e8f904d
BLAKE2b-256 629fbb9fa6d7e59149d77b0e806dccfc218d1a7d1ca89fc97cca1a4f0caa7c03

See more details on using hashes here.

File details

Details for the file reuse-1.1.0-cp311-cp311-manylinux_2_36_x86_64.whl.

File metadata

  • Download URL: reuse-1.1.0-cp311-cp311-manylinux_2_36_x86_64.whl
  • Upload date:
  • Size: 180.1 kB
  • Tags: CPython 3.11, manylinux: glibc 2.36+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.11.0 Linux/6.0.9-300.fc37.x86_64

File hashes

Hashes for reuse-1.1.0-cp311-cp311-manylinux_2_36_x86_64.whl
Algorithm Hash digest
SHA256 b0f3fb9091ff513af04b555d14a4c529ab05f6a575ab192dd9b68244f1e0721d
MD5 c97dc68788cbc1c4a9981da9dc5c7060
BLAKE2b-256 1358c56959fdee9cb4988456985b69502f716e7fd738ed2fdc215ad3360d9549

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page