Skip to content

Commit f42baa8

Browse files
committed
feat: add download.py
1 parent a71722a commit f42baa8

File tree

5 files changed

+506
-10
lines changed

5 files changed

+506
-10
lines changed

.github/workflows/clang-tools-release.yml renamed to .github/workflows/release.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
name: Build clang-tools wheels
1+
name: Release Python Wheels
22

33
on:
4-
54
workflow_dispatch:
65
inputs:
76
llvm_version:
@@ -16,6 +15,12 @@ on:
1615
description: "Emulation builds to skip (e.g. qemu)"
1716
required: false
1817
default: ""
18+
pull_request:
19+
branches: [ main ]
20+
paths:
21+
- 'clang-format/**'
22+
- 'clang-tidy/**'
23+
- '.github/workflows/release.yml'
1924

2025
jobs:
2126
build-clang-format-wheels:
@@ -425,6 +430,7 @@ jobs:
425430
test-clang-tidy-sdist
426431
]
427432
runs-on: ubuntu-latest
433+
if: github.event_name == 'workflow_dispatch'
428434
permissions:
429435
contents: write
430436

@@ -472,11 +478,16 @@ jobs:
472478
473479
## Installation:
474480
```bash
475-
# Install clang-format
476-
pip install clang-format-${{ github.event.inputs.llvm_version }}-<platform>.whl
481+
# Get download.py script
482+
curl -sSL https://raw.githubusercontent.com/cpp-linter/clang-tools-wheel/main/download.py
483+
484+
# Download and install clang-format
485+
python3 download.py clang-format --version ${{ github.event.inputs.llvm_version }}
486+
pip install clang-format-*.whl
477487
478-
# Install clang-tidy
479-
pip install clang-tidy-${{ github.event.inputs.llvm_version }}-<platform>.whl
488+
# Download and install clang-tidy
489+
python3 download.py clang-tidy --version ${{ github.event.inputs.llvm_version }}
490+
pip install clang-tidy-*.whl
480491
```
481492
482493
## Assets:
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Test download.py
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'download.py'
8+
- '.github/workflows/test-download.yml'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- 'download.py'
13+
- '.github/workflows/test-download.yml'
14+
schedule:
15+
# Run tests weekly to ensure scripts work with latest releases
16+
- cron: '0 0 * * 0'
17+
workflow_dispatch:
18+
inputs:
19+
test_version:
20+
description: 'Specific version to test (e.g., 20.1.8)'
21+
required: false
22+
default: 20.1.8 # set a default version for manual runs
23+
test_tool:
24+
description: 'Tool to test (clang-format, clang-tidy, or both)'
25+
required: false
26+
default: 'both'
27+
type: choice
28+
options:
29+
- both
30+
- clang-format
31+
- clang-tidy
32+
33+
jobs:
34+
test-python-script:
35+
name: Test Python Script
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
os: [ubuntu-latest, windows-latest, macos-latest]
40+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
41+
tool: [clang-format, clang-tidy]
42+
exclude:
43+
# Skip some combinations to reduce CI time
44+
- os: windows-latest
45+
python-version: '3.8'
46+
- os: windows-latest
47+
python-version: '3.9'
48+
- os: macos-latest
49+
python-version: '3.8'
50+
- os: macos-latest
51+
python-version: '3.9'
52+
53+
runs-on: ${{ matrix.os }}
54+
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Python ${{ matrix.python-version }}
60+
uses: actions/setup-python@v4
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
64+
- name: Test script help functionality
65+
run: python3 download.py --help
66+
67+
- name: Test list platforms functionality (latest)
68+
run: python3 download.py ${{ matrix.tool }} --list-platforms
69+
70+
- name: Test list platforms functionality (specific version)
71+
if: ${{ github.event.inputs.test_version != '' || github.event_name == 'schedule' }}
72+
run: |
73+
VERSION="${{ github.event.inputs.test_version || '20.1.8' }}"
74+
python3 download.py ${{ matrix.tool }} --version $VERSION --list-platforms
75+
76+
- name: Create test output directory
77+
run: mkdir -p test-downloads
78+
79+
- name: Test download latest version
80+
run: |
81+
python3 download.py ${{ matrix.tool }} --output test-downloads
82+
83+
- name: Verify downloaded wheel (latest)
84+
shell: bash
85+
run: |
86+
ls -la test-downloads/
87+
# Check if wheel file exists
88+
if [ "$(ls test-downloads/${{ matrix.tool }}*.whl 2>/dev/null | wc -l)" -eq 0 ]; then
89+
# Try with underscore naming
90+
if [ "$(ls test-downloads/${{'${{ matrix.tool }}' | sed 's/-/_/g'}}*.whl 2>/dev/null | wc -l)" -eq 0 ]; then
91+
echo "ERROR: No wheel file found for ${{ matrix.tool }}"
92+
exit 1
93+
fi
94+
fi
95+
echo "✅ Successfully downloaded latest ${{ matrix.tool }} wheel"
96+
97+
- name: Test download specific version
98+
if: ${{ github.event.inputs.test_version != '' || github.event_name == 'schedule' }}
99+
run: |
100+
VERSION="${{ github.event.inputs.test_version || '20.1.8' }}"
101+
python3 download.py ${{ matrix.tool }} --version $VERSION --output test-downloads
102+
103+
- name: Verify downloaded wheel (specific version)
104+
if: ${{ github.event.inputs.test_version != '' || github.event_name == 'schedule' }}
105+
shell: bash
106+
run: |
107+
VERSION="${{ github.event.inputs.test_version || '20.1.8' }}"
108+
# Check if wheel file with specific version exists
109+
if [ "$(ls test-downloads/*$VERSION*.whl 2>/dev/null | wc -l)" -eq 0 ]; then
110+
echo "ERROR: No wheel file found for version $VERSION"
111+
exit 1
112+
fi
113+
echo "✅ Successfully downloaded ${{ matrix.tool }} wheel version $VERSION"
114+
115+
- name: Test wheel installation
116+
run: |
117+
pip install test-downloads/${{ matrix.tool }}*.whl
118+
119+
- name: Test installed tool functionality
120+
shell: bash
121+
run: |
122+
TOOL_NAME="${{ matrix.tool }}"
123+
TOOL_CMD="${TOOL_NAME//-/_}" # Replace hyphens with underscores
124+
125+
# Test basic functionality
126+
if command -v $TOOL_CMD &> /dev/null; then
127+
echo "✅ $TOOL_CMD is available in PATH"
128+
$TOOL_CMD --version || $TOOL_CMD --help | head -5
129+
else
130+
echo "⚠️ $TOOL_CMD not found in PATH, checking python module"
131+
python3 -m $TOOL_CMD --version || python3 -m $TOOL_CMD --help | head -5
132+
fi
133+
134+
- name: Test platform override functionality
135+
run: |
136+
# Test with a different but compatible platform
137+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
138+
python3 download.py ${{ matrix.tool }} --platform musllinux_1_2_x86_64 --output test-downloads/alt-platform
139+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
140+
# Test both Intel and ARM platforms on macOS
141+
python3 download.py ${{ matrix.tool }} --platform macosx_10_9_x86_64 --output test-downloads/alt-platform
142+
fi
143+
continue-on-error: true # Platform override might not have wheels for all versions

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ repos:
77
- id: end-of-file-fixer
88
- id: check-added-large-files
99
- id: check-merge-conflict
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.13.3
12+
hooks:
13+
- id: ruff-check
14+
- id: ruff-format

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,33 @@ This project provides **Python wheels** for clang-tools including `clang-format`
66

77
We aim to publish wheels for each major and minor release of `clang-format` and `clang-tidy`.
88

9-
## Use with pipx or uv
9+
## Quick Install
1010

11-
You can install clang-format or clang-tidy via [`pipx`](https://pypa.github.io/pipx/) or [`uv`](https://docs.astral.sh/uv/):
11+
Download the appropriate wheel for your platform automatically.
12+
13+
**Usage:**
1214

1315
```bash
14-
pipx install git+https://github.com/cpp-linter/clang-tools-wheel.git#subdirectory=clang-format
15-
pipx install git+https://github.com/cpp-linter/clang-tools-wheel.git#subdirectory=clang-tidy
16+
# Get download.py script
17+
curl -sSL https://raw.githubusercontent.com/cpp-linter/clang-tools-wheel/main/download.py
18+
19+
# Download latest clang-format for your platform
20+
python3 download.py clang-format
21+
22+
# Download latest clang-tidy for your platform
23+
python3 download.py clang-tidy
24+
25+
# Download specific version
26+
python3 download.py clang-format --version 20.1.8
27+
28+
# Download to specific directory
29+
python3 download.py clang-format --output ./wheels
30+
31+
# List all available platforms
32+
python3 download.py clang-format --list-platforms
33+
34+
# Override platform detection (advanced)
35+
python3 download.py clang-format --platform win_amd64
1636
```
1737

1838
## Use from pre-commit
@@ -32,6 +52,28 @@ repos:
3252
args: [--checks=.clang-tidy] # Loads checks from .clang-tidy file
3353
```
3454
55+
## Supported Platforms
56+
57+
| Platform | Architecture | Wheel Tag |
58+
|----------|-------------|-----------|
59+
| **macOS** | Intel (x86_64) | `macosx_10_9_x86_64` |
60+
| **macOS** | Apple Silicon (arm64) | `macosx_11_0_arm64` |
61+
| **Linux** | x86_64 (glibc) | `manylinux_2_27_x86_64` |
62+
| **Linux** | x86_64 (musl) | `musllinux_1_2_x86_64` |
63+
| **Linux** | aarch64 (glibc) | `manylinux_2_26_aarch64` |
64+
| **Linux** | aarch64 (musl) | `musllinux_1_2_aarch64` |
65+
| **Linux** | i686 (glibc) | `manylinux_2_26_i686` |
66+
| **Linux** | i686 (musl) | `musllinux_1_2_i686` |
67+
| **Linux** | ppc64le (glibc) | `manylinux_2_26_ppc64le` |
68+
| **Linux** | ppc64le (musl) | `musllinux_1_2_ppc64le` |
69+
| **Linux** | s390x (glibc) | `manylinux_2_26_s390x` |
70+
| **Linux** | s390x (musl) | `musllinux_1_2_s390x` |
71+
| **Linux** | armv7l (glibc) | `manylinux_2_31_armv7l` |
72+
| **Linux** | armv7l (musl) | `musllinux_1_2_armv7l` |
73+
| **Windows** | 64-bit | `win_amd64` |
74+
| **Windows** | 32-bit | `win32` |
75+
| **Windows** | ARM64 | `win_arm64` |
76+
3577
## Acknowledgements
3678

3779
This project builds on the excellent work of:

0 commit comments

Comments
 (0)