|
1 | | -# Migration Guide: From clang-tools to Python Wheels |
| 1 | +# Migration: From Clang Tools Binaries to Python Wheels |
2 | 2 |
|
3 | 3 | ## Overview |
4 | 4 |
|
5 | | -Starting from version 0.9.0, `cpp-linter-hooks` has migrated from using the `clang-tools` package to using Python wheel packages for `clang-format` and `clang-tidy`. This change provides better cross-platform compatibility, easier installation, and more reliable dependency management. |
| 5 | +Starting from version **v1.0.0**, `cpp-linter-hooks` has migrated from using the `clang-tools` package to using Python wheel packages for `clang-format` and `clang-tidy`. This change provides: |
| 6 | + |
| 7 | +- **Better cross-platform compatibility** |
| 8 | +- **Easier installation and dependency management** |
| 9 | +- **Improved performance and reliability** |
| 10 | +- **More predictable version management** |
6 | 11 |
|
7 | 12 | ## What Changed |
8 | 13 |
|
9 | | -### Dependencies |
10 | | -- **Before**: Used `clang-tools==0.15.1` package |
11 | | -- **After**: Uses `clang-format` and `clang-tidy` wheel packages from PyPI |
| 14 | +### Core Changes |
12 | 15 |
|
13 | | -### Installation Method |
14 | | -- **Before**: clang-format and clang-tidy were installed via `clang-tools` package which managed binaries |
15 | | -- **After**: clang-format and clang-tidy are installed as Python packages and available as executables |
| 16 | +| Aspect | Before (< v1.0.0) | After (≥ v1.0.0) | |
| 17 | +|--------|-------------------|-------------------| |
| 18 | +| **Installation** | `clang-tools` package (binary management) | Python wheel packages (`clang-format`, `clang-tidy`) | |
| 19 | +| **Distribution** | Single package for both tools | Separate packages for each tool | |
| 20 | +| **Version Control** | Limited version flexibility | Enhanced version management with pip | |
| 21 | +| **Performance** | Standard performance | Optimized wheel packages | |
16 | 22 |
|
17 | | -### Benefits of Migration |
| 23 | +### Implementation Details |
18 | 24 |
|
19 | | -1. **Better Cross-Platform Support**: Python wheels work consistently across different operating systems |
20 | | -2. **Simplified Installation**: No need to manage binary installations separately |
21 | | -3. **More Reliable**: No more issues with binary compatibility or single threaded execution |
22 | | -4. **Better Version Management**: Each tool version is a separate package release |
| 25 | +- **Dependencies**: Updated to use separate `clang-format==20.1.7` and `clang-tidy==20.1.0` Python wheels |
| 26 | +- **Installation Logic**: Enhanced with pip-based installation and runtime version checks |
| 27 | +- **Performance**: Pre-commit hooks can now run in parallel for better speed |
23 | 28 |
|
24 | 29 | ## Breaking Changes |
25 | 30 |
|
26 | 31 | ### For End Users |
27 | 32 |
|
28 | | -- **No breaking changes**: The pre-commit hook configuration remains exactly the same |
29 | | -- All existing `.pre-commit-config.yaml` files will continue to work without modification |
| 33 | +> **No breaking changes for end users** |
30 | 34 |
|
31 | | -### For Developers |
32 | | -- The internal `ensure_installed()` function now returns the tool name instead of a Path object |
33 | | -- The `util.py` module has been rewritten to use `shutil.which()` instead of `clang_tools.install` |
34 | | -- Tests have been updated to mock the new wheel-based installation |
| 35 | +- Your existing `.pre-commit-config.yaml` files will continue to work without modification |
| 36 | +- All hook configurations remain backward compatible |
| 37 | +- No changes required to your workflow |
35 | 38 |
|
36 | 39 | ## Migration Steps |
37 | 40 |
|
38 | 41 | ### For End Users |
39 | | -No action required! Your existing configuration will continue to work. |
40 | | - |
41 | | -### For Developers/Contributors |
42 | | -1. Update your development environment: |
43 | | - ```bash |
44 | | - pip install clang-format clang-tidy |
45 | | - ``` |
46 | 42 |
|
47 | | -2. If you were importing from the utility module: |
48 | | - ```python |
49 | | - # Before |
50 | | - from cpp_linter_hooks.util import ensure_installed |
51 | | - path = ensure_installed("clang-format", "18") |
52 | | - command = [str(path), "--version"] |
| 43 | +**No action required!** Your existing configuration will continue to work seamlessly. |
53 | 44 |
|
54 | | - # After |
55 | | - from cpp_linter_hooks.util import ensure_installed |
56 | | - tool_name = ensure_installed("clang-format", "18") |
57 | | - command = [tool_name, "--version"] |
58 | | - ``` |
| 45 | +However, we recommend updating to the latest version for: |
| 46 | +- Better performance |
| 47 | +- Enhanced reliability |
| 48 | +- Latest features and bug fixes |
59 | 49 |
|
60 | | -## Version Support |
| 50 | +#### Example Configuration (No Changes Needed) |
61 | 51 |
|
62 | | -The wheel packages support the same LLVM versions as before: |
63 | | -- LLVM 16, 17, 18, 19, 20+ |
64 | | -- The `--version` argument continues to work as expected |
| 52 | +```yaml |
| 53 | +repos: |
| 54 | + - repo: https://github.com/cpp-linter/cpp-linter-hooks |
| 55 | + rev: v1.0.0 # Use the latest version |
| 56 | + hooks: |
| 57 | + - id: clang-format |
| 58 | + args: [--style=Google] |
| 59 | + - id: clang-tidy |
| 60 | + args: [--checks=-*,readability-*] |
| 61 | +``` |
65 | 62 |
|
66 | 63 | ## Troubleshooting |
67 | 64 |
|
68 | | -### Tool Not Found Error |
69 | | -If you encounter "command not found" errors: |
70 | | - |
71 | | -1. Ensure the wheel packages are installed: |
72 | | - ```bash |
73 | | - pip install clang-format clang-tidy |
74 | | - ``` |
| 65 | +### Common Issues |
75 | 66 |
|
76 | | -2. Verify the tools are available: |
77 | | - ```bash |
78 | | - clang-format --version |
79 | | - clang-tidy --version |
80 | | - ``` |
81 | | - |
82 | | -3. Check that the tools are in your PATH: |
83 | | - ```bash |
84 | | - which clang-format |
85 | | - which clang-tidy |
86 | | - ``` |
87 | | - |
88 | | -### Version Mismatch |
89 | | -If you need a specific version, you can install it explicitly: |
| 67 | +#### Issue: Tool not found after migration |
| 68 | +**Solution**: Clear your pre-commit cache: |
90 | 69 | ```bash |
91 | | -pip install clang-format==18.1.8 |
92 | | -pip install clang-tidy==18.1.8 |
| 70 | +pre-commit clean |
| 71 | +pre-commit install |
| 72 | +``` |
| 73 | + |
| 74 | +#### Issue: Version mismatch errors |
| 75 | +**Solution**: Ensure you're using the latest version of `cpp-linter-hooks`: |
| 76 | +```yaml |
| 77 | +rev: v1.0.0 # Update to latest version |
93 | 78 | ``` |
94 | 79 |
|
95 | 80 | ## Support |
96 | 81 |
|
97 | | -If you encounter any issues after the migration, please: |
98 | | -1. Check this migration guide |
99 | | -2. Search existing [issues](https://github.com/cpp-linter/cpp-linter-hooks/issues) |
100 | | -3. Create a new issue with: |
101 | | - - Your operating system |
| 82 | +If you encounter issues after migration: |
| 83 | +
|
| 84 | +1. **Check this guide**: Review the troubleshooting section above |
| 85 | +2. **Search existing issues**: [GitHub Issues](https://github.com/cpp-linter/cpp-linter-hooks/issues) |
| 86 | +3. **Report new issues**: Include the following information: |
| 87 | + - Operating system and version |
102 | 88 | - Python version |
103 | | - - The exact error message |
| 89 | + - `cpp-linter-hooks` version |
| 90 | + - Complete error message/stack trace |
104 | 91 | - Your `.pre-commit-config.yaml` configuration |
105 | 92 |
|
106 | 93 | ## References |
107 | 94 |
|
108 | | -- [clang-format wheel package](https://github.com/ssciwr/clang-format-wheel) |
109 | | -- [clang-tidy wheel package](https://github.com/ssciwr/clang-tidy-wheel) |
110 | | -- [PyPI clang-format](https://pypi.org/project/clang-format/) |
111 | | -- [PyPI clang-tidy](https://pypi.org/project/clang-tidy/) |
| 95 | +### Official Packages |
| 96 | +- [clang-format Python wheel](https://pypi.org/project/clang-format/) - PyPI package |
| 97 | +- [clang-tidy Python wheel](https://pypi.org/project/clang-tidy/) - PyPI package |
| 98 | + |
| 99 | +### Source Repositories |
| 100 | +- [clang-format wheel source](https://github.com/ssciwr/clang-format-wheel) - GitHub repository |
| 101 | +- [clang-tidy wheel source](https://github.com/ssciwr/clang-tidy-wheel) - GitHub repository |
| 102 | + |
| 103 | +### Documentation |
| 104 | +- [cpp-linter-hooks Documentation](https://github.com/cpp-linter/cpp-linter-hooks) - Main repository |
| 105 | +- [Pre-commit Framework](https://pre-commit.com/) - Pre-commit documentation |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +**Happy linting!** |
0 commit comments