Skip to main content
Version: 2.4 (deprecated)

Backends

How to enable specific functionality.


Pants has some basic, non-language-specific functionality built in to its core. For example, you can count the lines of code under some directory in your repo:

Bash
$ ./pants count-loc 'src/**'
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
Python 13 155 50 22 83 5
BASH 2 261 29 22 210 10
JSON 2 25 0 0 25 0
...

However most Pants functionality, including all language-specific functionality, is provided via backends.

A backend is a Python package that implements some required functionality, and uses hooks to register itself with Pants. You enable a backend by listing it under the backend_packages config key in pants.toml.

For example, to enable Python support:

pants.toml
[GLOBAL]
backend_packages = ["pants.backend.python"]

Available backends

Activate by adding the backend to the option backend_packages in the [GLOBAL] scope in pants.toml.

BackendWhat it doesDocs
pants.backend.awslambda.pythonEnables generating an AWS Lambda zip file from Python code.Python support
pants.backend.codegen.protobuf.pythonEnables generating Python from Protocol Buffers. Includes gRPC support.Protobuf and gRPC
pants.backend.pythonCore Python support.Enabling Python support
pants.backend.python.mixed_interpreter_constraintsAdds the py-constraints goal for insights on Python interpreter constraints.Interpreter compatibility
pants.backend.python.lint.banditEnables Bandit, the Python security linter: https://bandit.readthedocs.io/en/latest/.Linters and formatters
pants.backend.python.lint.blackEnables Black, the Python autoformatter: https://black.readthedocs.io/en/stable/.Linters and formatters
pants.backend.python.lint.docformatterEnables Docformatter, the Python docstring autoformatter: https://github.com/myint/docformatter.Linters and formatters
pants.backend.python.lint.flake8Enables Flake8, the Python linter: https://flake8.pycqa.org/en/latest/.Linters and formatters
pants.backend.python.lint.isortEnables isort, the Python import autoformatter: https://timothycrosley.github.io/isort/.Linters and formatters
pants.backend.python.lint.pylintEnables Pylint, the Python linter: https://www.pylint.org.Linters and formatters
pants.backend.python.typecheck.mypyEnables MyPy, the Python type checker: https://mypy.readthedocs.io/en/stable/.typecheck