Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
bump_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
with:
python-version: '3.x'

Expand All @@ -34,7 +34,7 @@ jobs:
fi

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e #v7
with:
add-paths: "clang_tools/__init__.py"
commit-message: "chore: bump clang-tools-static-binaries to ${{ steps.bump.outputs.bump_tag }}"
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5

- name: Set up Python 3.10
uses: actions/setup-python@v5
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
with:
python-version: "3.10"

Expand Down Expand Up @@ -60,15 +60,15 @@ jobs:
- uses: actions/checkout@v5

- name: Set up Python 3.10
uses: actions/setup-python@v5
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
with:
python-version: "3.10"

- name: Build wheel
run: python -m pip wheel -w dist .

- name: Upload wheel as artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4
with:
name: clang-tools-pip_wheel
path: dist/*.whl
Expand All @@ -77,18 +77,18 @@ jobs:
needs: [build]
strategy:
matrix:
version: [ 8, 9, 10, 11, 12, 12.0.1, 13, 14, 15, 16, 17, 18, 19, 20 ]
version: [ 9, 10, 11, 12, 12.0.1, 13, 14, 15, 16, 17, 18, 19, 20, 21 ]
os: [ ubuntu-latest, macos-13, windows-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5
with:
python-version: "3.10"

- name: Download wheel artifact
uses: actions/download-artifact@v5
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5
with:
name: clang-tools-pip_wheel
path: dist/
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
shell: bash
run: |
case "${{ matrix.version }}" in
15|16|18|20)
15|16|18|20|21)
clang-format.exe --version
clang-tidy.exe --version
clang-query.exe --version
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*build
clang_tools.egg-info
clang_tools/__pycache__
__pycache__
dist
clang_tools/llvm-project*
.coverage*
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Supported versions
clang-format, clang-tidy, clang-query, clang-apply-replacements
***************************************************************
.. csv-table::
:header: "Version", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11", "10", "9", "8"
:header: "Version", "21", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11", "10", "9"
:stub-columns: 1

Linux,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
Expand Down
7 changes: 5 additions & 2 deletions clang_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""The clang-tools package's base module."""

import os
from .util import check_install_os


Expand All @@ -8,5 +9,7 @@
install_os = check_install_os()
suffix = ".exe" if install_os == "windows" else ""

# tag of https://github.com/cpp-linter/clang-tools-static-binaries/releases
release_tag = "master-b35c5633"
binary_repo = os.getenv(
"CLANG_TOOLS_REPO", "https://github.com/cpp-linter/clang-tools-static-binaries"
)
binary_tag = os.getenv("CLANG_TOOLS_TAG", "master-6e612956")
9 changes: 3 additions & 6 deletions clang_tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import sys
from typing import Optional, cast

from . import release_tag, install_os, RESET_COLOR, suffix, YELLOW
from . import binary_repo, binary_tag, install_os, RESET_COLOR, suffix, YELLOW
from .util import download_file, verify_sha512, get_sha_checksum, Version


Expand Down Expand Up @@ -63,7 +63,7 @@ def is_installed(tool_name: str, version: Version) -> Optional[Path]:
return path


def clang_tools_binary_url(tool: str, version: str, tag: str = release_tag) -> str:
def clang_tools_binary_url(tool: str, version: str) -> str:
"""Assemble the URL to the binary.

:param tool: The name of the tool to download.
Expand All @@ -72,10 +72,7 @@ def clang_tools_binary_url(tool: str, version: str, tag: str = release_tag) -> s

:returns: The URL used to download the specified tool.
"""
base_url = (
"https://github.com/cpp-linter/clang-tools-static-binaries/releases/download/"
+ tag
)
base_url = f"{binary_repo}/releases/download/" + binary_tag
download_url = f"{base_url}/{tool}-{version}_{install_os}-amd64{suffix}"
return download_url.replace(" ", "")

Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

self

usage

.. toctree::
:hidden:

Expand Down
20 changes: 20 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Using a Custom Binary Repository
--------------------------------

You can override the default source for downloading **clang-tools** by setting the following environment variables:

- ``CLANG_TOOLS_REPO`` – The URL of the binary repository
(default: ``https://github.com/cpp-linter/clang-tools-static-binaries``)
- ``CLANG_TOOLS_TAG`` – The release tag to download binaries from
(default: ``master-6e612956``)

**Example:**

If you want to use the repository at
``https://github.com/muttleyxd/clang-tools-static-binaries``,
configure your environment like this:

.. code-block:: bash

export CLANG_TOOLS_REPO=https://github.com/muttleyxd/clang-tools-static-binaries
export CLANG_TOOLS_TAG=master-6e612956 # Replace with the tag you need
30 changes: 30 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import nox


@nox.session
def lint(session: nox.Session) -> None:
"""Run linter"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", external=True)


@nox.session
def test(session: nox.Session) -> None:
"""Run tests"""
session.install("--upgrade", "pip")
session.install("-e", ".[dev]")
session.run("coverage", "run", "-m", "pytest", "tests/", external=True)


@nox.session
def docs(session: nox.Session) -> None:
"""Build docs"""
session.install("--upgrade", "pip")
session.install(".[docs]")
session.run("sphinx-build", "-b", "html", "docs/", "docs/_build/html")


@nox.session(name="docs-live")
def docs_live(session: nox.Session) -> None:
session.install(".[docs]")
session.run("sphinx-autobuild", "docs/", "docs/_build/html", external=True)
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ dev = [
"pre-commit",
"pytest",
]
docs = [
"sphinx",
"sphinx-autobuild",
"sphinx_immaterial",
]

[tool.setuptools]
zip-safe = false
Expand Down
1 change: 0 additions & 1 deletion tests/clang-format-12_linux-amd64.sha512sum

This file was deleted.

1 change: 0 additions & 1 deletion tests/clang-format-12_macosx-amd64.sha512sum

This file was deleted.

1 change: 0 additions & 1 deletion tests/clang-format-12_windows-amd64.sha512sum

This file was deleted.

1 change: 1 addition & 0 deletions tests/clang-format-21_linux-amd64.sha512sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c399d13b5cd5b7cb718773009ec656cf1e402e6a95eb931b5db0cc71235fa18e6fcfe63519393d977d0457de1737f5c9f5a7d6cff57eb1e678780b85768d67b7 clang-format-21_linux-amd64
1 change: 1 addition & 0 deletions tests/clang-format-21_macosx-amd64.sha512sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8084fbc7638c687983606a1ae0973720fe7fc068a9d94f88212b8c220fe3dcf0770a887a46b9eaa3818ac1dad81e62cc98822970df68d1fb7dec323c1be89007 clang-format-21_macosx-amd64
1 change: 1 addition & 0 deletions tests/clang-format-21_windows-amd64.sha512sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
40c290a38318fcaa28c83bc86fb8f465f1c748f7f93405ec19653fe99e58b54d71eab228065be36b7bd031dd63a8ed595ff6a909a883f06cad9300b6cb632a2e *clang-format-21_windows-amd64
12 changes: 4 additions & 8 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from clang_tools import install_os
from clang_tools.install import clang_tools_binary_url
from clang_tools.util import check_install_os, download_file, get_sha_checksum, Version
from clang_tools import release_tag


def test_check_install_os():
Expand All @@ -14,13 +13,10 @@ def test_check_install_os():
assert current_os in ("linux", "windows", "macosx")


@pytest.mark.parametrize(
"tag", [release_tag, pytest.param("latest", marks=pytest.mark.xfail)]
)
def test_download_file(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, tag: str):
def test_download_file(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
"""Test that deliberately fails to download a file."""
monkeypatch.chdir(str(tmp_path))
url = clang_tools_binary_url("clang-format", "12", tag=tag)
url = clang_tools_binary_url("clang-format", "21")
file_name = download_file(url, "file.tar.gz", True)
assert file_name is not None

Expand All @@ -29,10 +25,10 @@ def test_get_sha(monkeypatch: pytest.MonkeyPatch):
"""Test the get_sha() function used to fetch the
releases' corresponding SHA512 checksum."""
monkeypatch.chdir(PurePath(__file__).parent.as_posix())
expected = Path(f"clang-format-12_{install_os}-amd64.sha512sum").read_text(
expected = Path(f"clang-format-21_{install_os}-amd64.sha512sum").read_text(
encoding="utf-8"
)
url = clang_tools_binary_url("clang-format", "12", tag=release_tag)
url = clang_tools_binary_url("clang-format", "21")
assert get_sha_checksum(url) == expected


Expand Down
Loading