Skip to content

clang-tools CLI

PyPI version Test codecov SonarCloud Platform Downloads

Easily install clang-format, clang-tidy, clang-query, clang-apply-replacements, and clang-include-cleaner static binaries or Python wheels using the clang-tools CLI.

Important

This package only manages binary executables (& corresponding symbolic links) that are installed using this package's executable script. It does not intend to change or modify any binary executable installed from other sources (like LLVM releases).

For Python wheels, this CLI supports clang-format, clang-tidy, clang-include-cleaner, and clang-apply-replacements tools.

Features

  • Install clang-format, clang-tidy, clang-query, clang-apply-replacements, and clang-include-cleaner via a single clang-tools CLI.
  • Supports both static binaries (standalone executables) and Python wheels (installed via pip).
  • Automatically uses static binaries when available; falls back to wheels if not.
  • Works on Linux, macOS, and Windows (x86_64 and ARM64).
  • Choose a specific LLVM version (11–22) or install the latest.
  • Install only the tools you need with --tool.
  • Uses SHA512 checksums to verify downloaded binaries.
  • Creates unversioned symlinks (e.g., clang-format) alongside versioned binaries (clang-format-18) for convenience.

    Note

    To create symbolic links on Windows, you must enable developer mode from the Windows settings under "Privacy & security" > "For developers" category.

  • Install to any directory with --directory.

  • Uninstall with clang-tools uninstall.

Install clang-tools CLI

Tip

It is recommended to use this package in a virtual environment.

# create the virtual env in the working directory
python -m venv env-name

# to activate on Linux:
source env-name/bin/activate

# to activate on Windows:
./env-name/Scripts/activate

This will ensure that

  1. there are no permission problems when installing the tool
  2. the installed path (for MacOS and Windows) is within the environment's variable PATH.

Install clang-tools command with pip:

pip install clang-tools

Install clang-tools from git repo:

pip install git+https://github.com/cpp-linter/clang-tools-pip.git@main

CLI Usage

For a list of supported Command Line Interface options, see:

Install binaries examples

Use clang-tools to install tools. Positional arguments are always tool names; version is specified via --version:

# Install latest clang-format (auto-detect: tries binary with --version, else wheel)
clang-tools install clang-format

# Install specific version (auto-detect: binary first, fall back to wheel)
clang-tools install clang-format --version 13

# Install to a specified directory
clang-tools install clang-format --version 13 --directory .

# Install multiple tools
clang-tools install clang-format clang-tidy --version 14

If the installed directory is in your path, you can run the installed tools:

clang-format-13 --version
# clang-format version 13.0.0

clang-tidy-13 --version
# LLVM (http://llvm.org/):
#   LLVM version 13.0.0
#   Optimized build.
#   Default target: x86_64-unknown-linux-gnu
#   Host CPU: skylake

Install wheels examples

After installing the clang-tools CLI, you can install the Python wheels using the unified clang-tools command.

Important

Wheel installation resolves the latest matching version from PyPI (e.g. --version 18 finds 18.1.8). If you know the exact version, pip install <tool>==<version> is equivalent and more direct.

# Install latest clang-format wheel
clang-tools install clang-format --version 21

# Install latest clang-tidy wheel
clang-tools install clang-tidy --version 21

Supported Versions

clang tools binaries

The following table shows the supported versions of clang-format, clang-tidy, clang-query, and clang-apply-replacements binaries for each platform:

Platform 22 21 20 19 18 17 16 15 14 13 12 11
Linux ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Windows ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
macOS ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

For more details, visit the clang-tools-static-binaries repository.

clang tools Python wheels

The following Python wheels are supported:

Check the respective PyPI pages for available versions and platform support.