cppcheck-py 2.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "monthly"
@@ -0,0 +1,218 @@
1
+ name: Build + Release Wheels
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v?[0-9]+.[0-9]+'
7
+ - 'v?[0-9]+.[0-9]+.[0-9]+'
8
+ workflow_dispatch:
9
+ inputs:
10
+ cppcheck_version:
11
+ description: "Cppcheck version to build"
12
+ required: false
13
+ default: ""
14
+ wheel_version:
15
+ description: "Version of the wheel packaging (appended to Cppcheck version)"
16
+ required: false
17
+ default: "0"
18
+ skip_emulation:
19
+ description: "Emulation builds to skip (e.g. qemu)"
20
+ required: false
21
+ default: ""
22
+ deploy_to_testpypi:
23
+ description: "Whether the build should be deployed to test.pypi.org instead regular PyPI"
24
+ required: true
25
+ default: 'false'
26
+
27
+ jobs:
28
+ build-wheels:
29
+ name: "${{ matrix.os }} :: ${{ matrix.platform }}-${{ matrix.arch }}"
30
+ runs-on: ${{ matrix.os }}
31
+
32
+ strategy:
33
+ fail-fast: false # Prevents other matrix jobs from being canceled if one fails
34
+ matrix:
35
+ # emulated linux: generate 4 matrix combinations with qemu on ubuntu:
36
+ arch: ["ppc64le", "s390x"]
37
+ platform: ["manylinux", "musllinux"]
38
+ os: [ubuntu-latest]
39
+ emulation: ["qemu"]
40
+ exclude:
41
+ # conditionally skip jobs requiring emulation:
42
+ - os: ubuntu-latest
43
+ emulation: ${{ github.event.inputs.skip_emulation }}
44
+ include:
45
+ # linux
46
+ - os: ubuntu-latest
47
+ platform: "manylinux"
48
+ arch: "x86_64"
49
+ - os: ubuntu-latest
50
+ platform: "manylinux"
51
+ arch: "i686"
52
+ - os: ubuntu-latest
53
+ platform: "musllinux"
54
+ arch: "x86_64"
55
+ - os: ubuntu-latest
56
+ platform: "musllinux"
57
+ arch: "i686"
58
+ - os: ubuntu-24.04-arm
59
+ platform: "manylinux"
60
+ arch: "aarch64"
61
+ - os: ubuntu-24.04-arm
62
+ platform: "musllinux"
63
+ arch: "aarch64"
64
+ - os: ubuntu-24.04-arm
65
+ platform: "manylinux"
66
+ arch: "armv7l"
67
+ - os: ubuntu-24.04-arm
68
+ platform: "musllinux"
69
+ arch: "armv7l"
70
+ # windows
71
+ - os: windows-latest
72
+ platform: "win"
73
+ arch: "AMD64"
74
+ #- os: windows-latest
75
+ # platform: "win"
76
+ # arch: "x86"
77
+ #- os: windows-11-arm
78
+ # platform: "win"
79
+ # arch: "ARM64"
80
+ # macos
81
+ - os: macos-15-intel
82
+ platform: "macos"
83
+ arch: "x86_64"
84
+ - os: macos-latest
85
+ platform: "macos"
86
+ arch: "arm64"
87
+
88
+ steps:
89
+ - uses: actions/checkout@v7
90
+
91
+ - name: Support long paths on Windows
92
+ if: runner.os == 'Windows'
93
+ run: git config --system core.longpaths true
94
+
95
+ - name: Set up msvc on Windows
96
+ if: runner.os == 'Windows'
97
+ uses: ilammy/msvc-dev-cmd@v1
98
+ with:
99
+ arch: ${{ matrix.arch }}
100
+
101
+ - name: Remove strip binaries on arm64 windows runner to avoid "file format not recognized" error when running strip
102
+ if: matrix.platform == 'win' && matrix.arch == 'ARM64'
103
+ run: |
104
+ rm C:\mingw64\bin\strip.exe
105
+ rm C:\Strawberry\c\bin\strip.exe
106
+
107
+ - name: Override Cppcheck version (${{ github.event.inputs.cppcheck_version }})
108
+ if: github.event.inputs.cppcheck_version
109
+ run: |
110
+ echo "${{ github.event.inputs.cppcheck_version }}.${{ github.event.inputs.wheel_version }}" > cppcheck_version.txt
111
+ cat cppcheck_version.txt
112
+
113
+ - name: Set up QEMU
114
+ uses: docker/setup-qemu-action@v4.2.0
115
+ with:
116
+ image: tonistiigi/binfmt:qemu-v8.1.5
117
+ if: runner.os == 'Linux' && matrix.emulation == 'qemu'
118
+
119
+ - name: Build wheels
120
+ uses: pypa/cibuildwheel@v4.1
121
+ env:
122
+ CIBW_ARCHS: "${{ matrix.arch }}"
123
+ # restrict to a single Python version as wheel does not depend on Python:
124
+ CIBW_BUILD: "cp311-${{ matrix.platform }}*"
125
+ # Use a newer manylinux image for armv7l builds
126
+ CIBW_MANYLINUX_ARMV7L_IMAGE: manylinux_2_35
127
+
128
+ - uses: actions/upload-artifact@v7
129
+ with:
130
+ name: artifacts-wheels-${{ matrix.platform }}-${{ matrix.arch }}
131
+ path: ./wheelhouse/*.whl
132
+
133
+ build-sdist:
134
+ name: Build source distribution
135
+ runs-on: ubuntu-latest
136
+
137
+ steps:
138
+ - uses: actions/checkout@v7
139
+
140
+ - name: Override Cppcheck version (${{ github.event.inputs.cppcheck_version }})
141
+ if: github.event.inputs.cppcheck_version
142
+ run: |
143
+ echo "${{ github.event.inputs.cppcheck_version }}.${{ github.event.inputs.wheel_version }}" > cppcheck_version.txt
144
+ cat cppcheck_version.txt
145
+
146
+ - name: Build SDist
147
+ run: pipx run build --sdist
148
+
149
+ - uses: actions/upload-artifact@v7
150
+ with:
151
+ name: artifacts-sdist
152
+ path: dist/*.tar.gz
153
+
154
+ test-sdist:
155
+ name: Test build from source distribution
156
+ needs: [build-sdist]
157
+ runs-on: ubuntu-latest
158
+
159
+ steps:
160
+ - uses: actions/checkout@v7
161
+
162
+ - uses: actions/setup-python@v6
163
+ name: Install Python
164
+ with:
165
+ python-version: '3.13'
166
+
167
+ - uses: actions/download-artifact@v8
168
+ with:
169
+ name: artifacts-sdist
170
+ path: sdist
171
+
172
+ - name: Install from SDist
173
+ run:
174
+ pip install sdist/*.tar.gz
175
+
176
+ - name: Install test requirements
177
+ run:
178
+ pip install --group dev
179
+
180
+ - name: Set up Git identity
181
+ run: |
182
+ git config --global user.name Name
183
+ git config --global user.email foo@bar.com
184
+
185
+ - name: Run test suite
186
+ working-directory: test
187
+ run:
188
+ python -m pytest -vvv
189
+
190
+ upload_pypi:
191
+ name: Upload to PyPI
192
+ needs: [build-wheels, build-sdist, test-sdist]
193
+ runs-on: ubuntu-latest
194
+ permissions:
195
+ id-token: write
196
+ contents: write
197
+ if: github.repository_owner == 'cconverse711'
198
+
199
+ steps:
200
+ - uses: actions/download-artifact@v8
201
+ with:
202
+ pattern: artifacts-*
203
+ merge-multiple: true
204
+ path: dist
205
+
206
+ - name: Upload to PyPI
207
+ uses: pypa/gh-action-pypi-publish@v1.14.0
208
+ if: (startsWith(github.event.ref, 'refs/tags/')) || (github.event.inputs.deploy_to_testpypi == 'false')
209
+
210
+ - name: Upload to TestPyPI
211
+ uses: pypa/gh-action-pypi-publish@v1.14.0
212
+ if: github.event.inputs.deploy_to_testpypi == 'true'
213
+ with:
214
+ repository-url: https://test.pypi.org/legacy/
215
+
216
+ - name: GitHub release for tagged commits
217
+ uses: softprops/action-gh-release@v3
218
+ if: startsWith(github.ref, 'refs/tags/')
@@ -0,0 +1,182 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # pytype static type analyzer
135
+ .pytype/
136
+
137
+ # Cython debug symbols
138
+ cython_debug/
139
+ # Prerequisites
140
+ *.d
141
+
142
+ # Compiled Object files
143
+ *.slo
144
+ *.lo
145
+ *.o
146
+ *.obj
147
+
148
+ # Precompiled Headers
149
+ *.gch
150
+ *.pch
151
+
152
+ # Compiled Dynamic libraries
153
+ *.so
154
+ *.dylib
155
+ *.dll
156
+
157
+ # Fortran module files
158
+ *.mod
159
+ *.smod
160
+
161
+ # Compiled Static libraries
162
+ *.lai
163
+ *.la
164
+ *.a
165
+ *.lib
166
+
167
+ # Executables
168
+ *.exe
169
+ *.out
170
+ *.app
171
+
172
+ CMakeLists.txt.user
173
+ CMakeCache.txt
174
+ CMakeFiles
175
+ CMakeScripts
176
+ Testing
177
+ Makefile
178
+ cmake_install.cmake
179
+ install_manifest.txt
180
+ compile_commands.json
181
+ CTestTestfile.cmake
182
+ _deps
@@ -0,0 +1,42 @@
1
+ ci:
2
+ autoupdate_commit_msg: "chore(deps): update pre-commit hooks"
3
+ autofix_commit_msg: "style: pre-commit fixes"
4
+ autoupdate_schedule: "monthly"
5
+
6
+ repos:
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: v6.0.0
9
+ hooks:
10
+ - id: check-added-large-files
11
+ - id: check-case-conflict
12
+ - id: check-merge-conflict
13
+ - id: check-symlinks
14
+ - id: check-yaml
15
+ - id: check-toml
16
+ - id: debug-statements
17
+ - id: end-of-file-fixer
18
+ - id: mixed-line-ending
19
+ - id: trailing-whitespace
20
+
21
+ - repo: https://github.com/astral-sh/ruff-pre-commit
22
+ rev: v0.16.6
23
+ hooks:
24
+ - id: ruff-check
25
+ args: [--fix, --show-fixes]
26
+ # Run the formatter.
27
+ - id: ruff-format
28
+
29
+ - repo: https://github.com/BlankSpruce/gersemi-pre-commit
30
+ rev: 0.28.1
31
+ hooks:
32
+ - id: gersemi
33
+ - repo: https://github.com/adhtruong/mirrors-typos
34
+ rev: v1.50.1
35
+ hooks:
36
+ - id: typos
37
+ - repo: https://github.com/abravalheri/validate-pyproject
38
+ rev: "0.26"
39
+ hooks:
40
+ - id: validate-pyproject
41
+ # Optional extra validations from SchemaStore:
42
+ additional_dependencies: ["validate-pyproject-schema-store[all]"]
@@ -0,0 +1,88 @@
1
+ cmake_minimum_required(VERSION 3.16...4.0)
2
+ project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION})
3
+
4
+ message(STATUS "cppcheck-wheel version: ${SKBUILD_PROJECT_VERSION}")
5
+ string(
6
+ REGEX MATCH "^([0-9]+)\.([0-9]+)"
7
+ CPPCHECK_VERSION
8
+ "${SKBUILD_PROJECT_VERSION}"
9
+ )
10
+ message(STATUS "cppcheck version: ${CPPCHECK_VERSION}")
11
+
12
+ # Define a build rule for cppcheck
13
+ set(CPPCHECK_DOWNLOAD_URL
14
+ "https://github.com/cppcheck-opensource/cppcheck/archive/refs/tags/${CPPCHECK_VERSION}.tar.gz"
15
+ )
16
+ include(ExternalProject)
17
+ ExternalProject_Add(
18
+ build-cppcheck
19
+ URL "${CPPCHECK_DOWNLOAD_URL}"
20
+ SOURCE_DIR ${CMAKE_BINARY_DIR}/cppcheck
21
+ BINARY_DIR ${CMAKE_BINARY_DIR}/cppcheck-build
22
+ DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/cppcheck-download
23
+ UPDATE_COMMAND ""
24
+ INSTALL_COMMAND ""
25
+ USES_TERMINAL_DOWNLOAD 1
26
+ USES_TERMINAL_CONFIGURE 1
27
+ USES_TERMINAL_BUILD 1
28
+ CMAKE_ARGS
29
+ -DCMAKE_BUILD_TYPE=Release -U FILESDIR
30
+ -DCMAKE_POLICY_VERSION_MINIMUM=3.5
31
+ BUILD_COMMAND ${CMAKE_COMMAND} --build . --target cppcheck --config Release
32
+ )
33
+ set(config-subfolder "")
34
+ if(CMAKE_GENERATOR MATCHES "Visual Studio")
35
+ set(config-subfolder "Release")
36
+ endif()
37
+ set(cppcheck-executable
38
+ ${CMAKE_BINARY_DIR}/cppcheck-build/${config-subfolder}/bin/cppcheck${CMAKE_EXECUTABLE_SUFFIX}
39
+ )
40
+
41
+ # Reduce the size of the executable by executing strip if it is present on the system
42
+ find_program(STRIP_EXECUTABLE strip)
43
+ if(STRIP_EXECUTABLE)
44
+ add_custom_target(
45
+ strip-cppcheck
46
+ ALL
47
+ COMMAND ${STRIP_EXECUTABLE} ${cppcheck-executable}
48
+ COMMENT "Stripping cppcheck executable for size reduction"
49
+ )
50
+ add_dependencies(strip-cppcheck build-cppcheck)
51
+ endif()
52
+
53
+ # Define an installation rule that copies the executable to our Python package
54
+ install(
55
+ PROGRAMS
56
+ ${cppcheck-executable}
57
+ ${CMAKE_BINARY_DIR}/cppcheck/htmlreport/cppcheck-htmlreport
58
+ DESTINATION cppcheck/data
59
+ )
60
+
61
+ install(
62
+ DIRECTORY ${CMAKE_BINARY_DIR}/cppcheck/addons
63
+ DESTINATION cppcheck/data
64
+ FILES_MATCHING
65
+ PATTERN "*.py"
66
+ PATTERN "test" EXCLUDE
67
+ )
68
+
69
+ install(
70
+ DIRECTORY ${CMAKE_BINARY_DIR}/cppcheck/cfg
71
+ DESTINATION cppcheck/data
72
+ FILES_MATCHING
73
+ PATTERN "*.cfg"
74
+ )
75
+
76
+ install(
77
+ DIRECTORY ${CMAKE_BINARY_DIR}/cppcheck/platforms
78
+ DESTINATION cppcheck/data
79
+ FILES_MATCHING
80
+ PATTERN "*.xml"
81
+ )
82
+
83
+ # Install the downloaded source archive for GPLv3 compliance.
84
+ install(
85
+ FILES ${CMAKE_BINARY_DIR}/cppcheck-download/${CPPCHECK_VERSION}.tar.gz
86
+ DESTINATION cppcheck
87
+ RENAME cppcheck-${CPPCHECK_VERSION}.tar.gz
88
+ )
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License.
62
+
63
+ Subject to the terms and conditions of this License, each Contributor hereby
64
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the Work and such
67
+ Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License.
70
+
71
+ Subject to the terms and conditions of this License, each Contributor hereby
72
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73
+ irrevocable (except as stated in this section) patent license to make, have
74
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75
+ such license applies only to those patent claims licensable by such Contributor
76
+ that are necessarily infringed by their Contribution(s) alone or by combination
77
+ of their Contribution(s) with the Work to which such Contribution(s) was
78
+ submitted. If You institute patent litigation against any entity (including a
79
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80
+ Contribution incorporated within the Work constitutes direct or contributory
81
+ patent infringement, then any patent licenses granted to You under this License
82
+ for that Work shall terminate as of the date such litigation is filed.
83
+
84
+ 4. Redistribution.
85
+
86
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
87
+ in any medium, with or without modifications, and in Source or Object form,
88
+ provided that You meet the following conditions:
89
+
90
+ You must give any other recipients of the Work or Derivative Works a copy of
91
+ this License; and
92
+ You must cause any modified files to carry prominent notices stating that You
93
+ changed the files; and
94
+ You must retain, in the Source form of any Derivative Works that You distribute,
95
+ all copyright, patent, trademark, and attribution notices from the Source form
96
+ of the Work, excluding those notices that do not pertain to any part of the
97
+ Derivative Works; and
98
+ If the Work includes a "NOTICE" text file as part of its distribution, then any
99
+ Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of the
102
+ following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents of
106
+ the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions.
118
+
119
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
120
+ for inclusion in the Work by You to the Licensor shall be under the terms and
121
+ conditions of this License, without any additional terms or conditions.
122
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
123
+ any separate license agreement you may have executed with Licensor regarding
124
+ such Contributions.
125
+
126
+ 6. Trademarks.
127
+
128
+ This License does not grant permission to use the trade names, trademarks,
129
+ service marks, or product names of the Licensor, except as required for
130
+ reasonable and customary use in describing the origin of the Work and
131
+ reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty.
134
+
135
+ Unless required by applicable law or agreed to in writing, Licensor provides the
136
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138
+ including, without limitation, any warranties or conditions of TITLE,
139
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140
+ solely responsible for determining the appropriateness of using or
141
+ redistributing the Work and assume any risks associated with Your exercise of
142
+ permissions under this License.
143
+
144
+ 8. Limitation of Liability.
145
+
146
+ In no event and under no legal theory, whether in tort (including negligence),
147
+ contract, or otherwise, unless required by applicable law (such as deliberate
148
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special, incidental,
150
+ or consequential damages of any character arising as a result of this License or
151
+ out of the use or inability to use the Work (including but not limited to
152
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153
+ any and all other commercial damages or losses), even if such Contributor has
154
+ been advised of the possibility of such damages.
155
+
156
+ 9. Accepting Warranty or Additional Liability.
157
+
158
+ While redistributing the Work or Derivative Works thereof, You may choose to
159
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160
+ other liability obligations and/or rights consistent with this License. However,
161
+ in accepting such obligations, You may act only on Your own behalf and on Your
162
+ sole responsibility, not on behalf of any other Contributor, and only if You
163
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
164
+ incurred by, or claims asserted against, such Contributor by reason of your
165
+ accepting any such warranty or additional liability.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+ APPENDIX: How to apply the Apache License to your work
170
+
171
+ To apply the Apache License to your work, attach the following boilerplate
172
+ notice, with the fields enclosed by brackets "[]" replaced with your own
173
+ identifying information. (Don't include the brackets!) The text should be
174
+ enclosed in the appropriate comment syntax for the file format. We also
175
+ recommend that a file or class name and description of purpose be included on
176
+ the same "printed page" as the copyright notice for easier identification within
177
+ third-party archives.
178
+
179
+ Copyright [yyyy] [name of copyright owner]
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.2
2
+ Name: cppcheck-py
3
+ Version: 2.9
4
+ Summary: Static analysis of C/C++ code
5
+ License: Apache 2.0
6
+ Classifier: Programming Language :: C
7
+ Classifier: Programming Language :: C++
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Software Development :: Quality Assurance
12
+ Project-URL: Homepage, https://cppcheck.sourceforge.io/
13
+ Project-URL: Documentation, https://cppcheck.sourceforge.io/manual.pdf
14
+ Project-URL: Download, https://github.com/cppcheck-opensource/cppcheck/releases
15
+ Project-URL: Source, https://github.com/cconverse711/cppcheck-wheel
16
+ Requires-Python: >=3.9
17
+ Requires-Dist: pygments
18
+ Description-Content-Type: text/markdown
19
+
20
+ # Cppcheck Python distribution
21
+
22
+ [![PyPI Release](https://img.shields.io/pypi/v/cppcheck-py.svg)](https://pypi.org/project/cppcheck-py)
23
+
24
+ This project packages the `cppcheck` utility as a Python package. It allows you to install `cppcheck` directly from PyPI:
25
+
26
+ ```
27
+ python -m pip install cppcheck-py
28
+ ```
29
+
30
+ The tools provided are:
31
+
32
+ cppcheck: performs static analysis of C/C++ source code
33
+ cppcheck-htmlreport: generates an html report of a XML file produced by cppcheck
34
+
35
+ This projects intends to release a new PyPI package for each major and minor release of `cppcheck`.
36
+
37
+ ## Use with pipx
38
+
39
+ You can use `pipx` to run cppcheck, as well. For example, `pipx run cppcheck <args>` will run cppcheck without any previous install required on any machine with pipx (including all default GitHub Actions / Azure runners, avoiding requiring a pre-install step or even `actions/setup-python`).
40
+
41
+ ## Building new releases
42
+
43
+ The [cppcheck-wheel repository](https://github.com/cconverse711/cppcheck-wheel) provides the logic to build and publish binary wheels of the `cppcheck` utility.
44
+
45
+ In order to add a new release, the following steps are necessary:
46
+
47
+ * Edit the [version file](https://github.com/cconverse711/clang-format-wheel/blob/main/cppcheck_version.txt)
48
+ * In the form `cppcheck_version.wheel_version`, e.g. `2.21.0.1`
49
+ * Tag the commit with this version to trigger the [GitHub Actions release workflow](https://github.com/cconverse711/cppcheck-wheel/actions/workflows/release.yml)
50
+ * e.g. `git tag v2.21.0.1 && git push origin v2.21.0.1`
51
+
52
+ Alternatively, the workflow can be triggered manually:
53
+
54
+ On manual triggers, the following input variables are available:
55
+ * `cppcheck_version`: Override the Cppcheck version (default: `""`)
56
+ * `wheel_version`: Override the wheel packaging version (default `"0"`)
57
+ * `skip_emulation`: Set which emulation builds to skip, e.g. `"qemu"` (default: `""`)
58
+ * `deploy_to_testpypi`: Whether to deploy to TestPyPI instead of PyPI (default: `false`)
59
+
60
+ The repository with the precommit hook is automatically updated using a scheduled Github Actions workflow.
61
+
62
+ ## Acknowledgements
63
+
64
+ This repository extends the great work of several other projects:
65
+
66
+ * `cppcheck` itself is [provided by the Cppcheck project](https://github.com/cppcheck-opensource/cppcheck) under the GPL-3.0 License.
67
+ * The repository is inspired by [clang-format-wheel](https://github.com/ssciwr/clang-format-wheel) and [clang-tidy-wheel](https://github.com/ssciwr/clang-tidy-wheel) which are in turn based on [scikit-build-core](https://github.com/scikit-build/scikit-build-core) which greatly reduces the amount of low level code necessary to package `cppcheck`.
68
+ * The `scikit-build` packaging examples of [CMake](https://github.com/scikit-build/cmake-python-distributions) and [Ninja](https://github.com/scikit-build/ninja-python-distributions) were very helpful in packaging `cppcheck`.
69
+ * The CI build process is controlled by [cibuildwheel](https://github.com/pypa/cibuildwheel) which makes building wheels across a number of platforms a pleasant experience (!)
70
+
71
+ We are grateful for the generous provisioning with CI resources that GitHub currently offers to Open Source projects.
72
+
73
+ ## Troubleshooting
74
+
75
+ To see which cppcheck binary the package is using
76
+ you can set `CPPCHECK_WHEEL_VERBOSE` to `1` in your environment.
@@ -0,0 +1,57 @@
1
+ # Cppcheck Python distribution
2
+
3
+ [![PyPI Release](https://img.shields.io/pypi/v/cppcheck-py.svg)](https://pypi.org/project/cppcheck-py)
4
+
5
+ This project packages the `cppcheck` utility as a Python package. It allows you to install `cppcheck` directly from PyPI:
6
+
7
+ ```
8
+ python -m pip install cppcheck-py
9
+ ```
10
+
11
+ The tools provided are:
12
+
13
+ cppcheck: performs static analysis of C/C++ source code
14
+ cppcheck-htmlreport: generates an html report of a XML file produced by cppcheck
15
+
16
+ This projects intends to release a new PyPI package for each major and minor release of `cppcheck`.
17
+
18
+ ## Use with pipx
19
+
20
+ You can use `pipx` to run cppcheck, as well. For example, `pipx run cppcheck <args>` will run cppcheck without any previous install required on any machine with pipx (including all default GitHub Actions / Azure runners, avoiding requiring a pre-install step or even `actions/setup-python`).
21
+
22
+ ## Building new releases
23
+
24
+ The [cppcheck-wheel repository](https://github.com/cconverse711/cppcheck-wheel) provides the logic to build and publish binary wheels of the `cppcheck` utility.
25
+
26
+ In order to add a new release, the following steps are necessary:
27
+
28
+ * Edit the [version file](https://github.com/cconverse711/clang-format-wheel/blob/main/cppcheck_version.txt)
29
+ * In the form `cppcheck_version.wheel_version`, e.g. `2.21.0.1`
30
+ * Tag the commit with this version to trigger the [GitHub Actions release workflow](https://github.com/cconverse711/cppcheck-wheel/actions/workflows/release.yml)
31
+ * e.g. `git tag v2.21.0.1 && git push origin v2.21.0.1`
32
+
33
+ Alternatively, the workflow can be triggered manually:
34
+
35
+ On manual triggers, the following input variables are available:
36
+ * `cppcheck_version`: Override the Cppcheck version (default: `""`)
37
+ * `wheel_version`: Override the wheel packaging version (default `"0"`)
38
+ * `skip_emulation`: Set which emulation builds to skip, e.g. `"qemu"` (default: `""`)
39
+ * `deploy_to_testpypi`: Whether to deploy to TestPyPI instead of PyPI (default: `false`)
40
+
41
+ The repository with the precommit hook is automatically updated using a scheduled Github Actions workflow.
42
+
43
+ ## Acknowledgements
44
+
45
+ This repository extends the great work of several other projects:
46
+
47
+ * `cppcheck` itself is [provided by the Cppcheck project](https://github.com/cppcheck-opensource/cppcheck) under the GPL-3.0 License.
48
+ * The repository is inspired by [clang-format-wheel](https://github.com/ssciwr/clang-format-wheel) and [clang-tidy-wheel](https://github.com/ssciwr/clang-tidy-wheel) which are in turn based on [scikit-build-core](https://github.com/scikit-build/scikit-build-core) which greatly reduces the amount of low level code necessary to package `cppcheck`.
49
+ * The `scikit-build` packaging examples of [CMake](https://github.com/scikit-build/cmake-python-distributions) and [Ninja](https://github.com/scikit-build/ninja-python-distributions) were very helpful in packaging `cppcheck`.
50
+ * The CI build process is controlled by [cibuildwheel](https://github.com/pypa/cibuildwheel) which makes building wheels across a number of platforms a pleasant experience (!)
51
+
52
+ We are grateful for the generous provisioning with CI resources that GitHub currently offers to Open Source projects.
53
+
54
+ ## Troubleshooting
55
+
56
+ To see which cppcheck binary the package is using
57
+ you can set `CPPCHECK_WHEEL_VERBOSE` to `1` in your environment.
@@ -0,0 +1,55 @@
1
+ import functools
2
+ import os
3
+ import subprocess
4
+ import sys
5
+ from importlib.resources import files
6
+ from pathlib import Path
7
+
8
+
9
+ def get_executable(name: str) -> Path:
10
+ return _get_executable(name)
11
+
12
+
13
+ @functools.cache
14
+ def _get_executable(name: str) -> Path:
15
+ possibles = [
16
+ Path(files("cppcheck") / f"data/{name}{s}")
17
+ for s in ("", ".exe", ".bin", ".dmg")
18
+ ]
19
+ for exe in possibles:
20
+ if exe.exists():
21
+ if os.environ.get("CPPCHECK_WHEEL_VERBOSE", None):
22
+ print(f"Found binary: {exe}")
23
+ return exe
24
+
25
+ possibles_str = "\n\t".join(map(str, possibles))
26
+ raise FileNotFoundError(f"No executable found for {name} at\n\t{possibles_str}")
27
+
28
+
29
+ def _run(name, *args):
30
+ command = [_get_executable(name)]
31
+ if args:
32
+ command += list(args)
33
+ else:
34
+ command += sys.argv[1:]
35
+ return subprocess.call(command)
36
+
37
+
38
+ def _run_python(name, *args):
39
+ command = [sys.executable, _get_executable(name)]
40
+ if args:
41
+ command += list(args)
42
+ else:
43
+ command += sys.argv[1:]
44
+
45
+ # as MS Windows is not able to run Python scripts directly by name,
46
+ # we have to call the interpreter and pass the script as parameter
47
+ return subprocess.call(command)
48
+
49
+
50
+ def cppcheck():
51
+ raise SystemExit(_run("cppcheck"))
52
+
53
+
54
+ def cppcheck_htmlreport():
55
+ raise SystemExit(_run_python("cppcheck-htmlreport"))
@@ -0,0 +1 @@
1
+ 2.9.0
@@ -0,0 +1,61 @@
1
+ [build-system]
2
+ requires = ["scikit-build-core"]
3
+ build-backend = "scikit_build_core.build"
4
+
5
+ [project]
6
+ name = "cppcheck-py"
7
+ dynamic = ["version"]
8
+ license = { text = "Apache 2.0" }
9
+ description = "Static analysis of C/C++ code"
10
+ readme = "README.md"
11
+ requires-python = ">=3.9"
12
+ dependencies = ["pygments"]
13
+ classifiers = [
14
+ "Programming Language :: C",
15
+ "Programming Language :: C++",
16
+ "Operating System :: OS Independent",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Intended Audience :: Developers",
19
+ "Topic :: Software Development :: Quality Assurance",
20
+ ]
21
+
22
+ [[tool.dynamic-metadata]]
23
+ provider = "scikit_build_core.metadata.regex"
24
+ field = "version"
25
+ regex = '^(?P<value>\d+\.\d+(\.[1-9]\d*)?)'
26
+ input = "cppcheck_version.txt"
27
+
28
+ [project.urls]
29
+ Homepage = "https://cppcheck.sourceforge.io/"
30
+ Documentation = "https://cppcheck.sourceforge.io/manual.pdf"
31
+ Download = "https://github.com/cppcheck-opensource/cppcheck/releases"
32
+ Source = "https://github.com/cconverse711/cppcheck-wheel"
33
+
34
+ [project.scripts]
35
+ "cppcheck" = "cppcheck:cppcheck"
36
+ "cppcheck-htmlreport" = "cppcheck:cppcheck_htmlreport"
37
+
38
+ [tool.scikit-build]
39
+ wheel.packages = ["cppcheck"]
40
+ wheel.py-api = "py3"
41
+ cmake.version = ">=3.16.0"
42
+ ninja.version = ">=1.10.0"
43
+ build.verbose = true
44
+ logging.level = "DEBUG"
45
+
46
+ [dependency-groups]
47
+ dev = ["pytest"]
48
+
49
+ [tool.pytest.ini_options]
50
+ # use importlib pytest import mode to avoid adding local directory to sys.path
51
+ addopts = "--import-mode=importlib"
52
+
53
+ [tool.cibuildwheel]
54
+ # Super-verbose output for debugging purpose
55
+ build-verbosity = 3
56
+ # Set CMAKE_GENERATOR env var which is respected by scikit-build-core to use Ninja on all platforms
57
+ environment = "CMAKE_GENERATOR=Ninja"
58
+
59
+ # Testing commands for our wheels
60
+ test-groups = ["dev"]
61
+ test-command = "pytest {package}/test -vvv"
File without changes
@@ -0,0 +1,82 @@
1
+ import os
2
+ import sys
3
+ import tempfile
4
+ from pathlib import Path
5
+
6
+ import pytest
7
+
8
+ EXECUTABLES = (
9
+ "cppcheck",
10
+ "cppcheck-htmlreport",
11
+ )
12
+
13
+
14
+ @pytest.fixture(autouse=True)
15
+ def ensure_cppcheck_from_wheel(monkeypatch):
16
+ """Test the installed cppcheck package, not the local one."""
17
+ this_dir = Path(__file__).resolve().parent
18
+
19
+ paths_to_remove = {
20
+ this_dir,
21
+ this_dir.parent,
22
+ }
23
+
24
+ sys.path[:] = [
25
+ path for path in sys.path if Path(path).resolve() not in paths_to_remove
26
+ ]
27
+
28
+ monkeypatch.delitem(sys.modules, "cppcheck", raising=False)
29
+
30
+
31
+ @pytest.mark.parametrize("executable", EXECUTABLES)
32
+ def test_executable_file(capsys, executable):
33
+ import cppcheck
34
+
35
+ cppcheck._get_executable.cache_clear()
36
+ exe = cppcheck.get_executable(executable)
37
+ assert os.path.exists(exe)
38
+ assert os.access(exe, os.X_OK)
39
+ assert capsys.readouterr().out == ""
40
+
41
+
42
+ def test_verbose_output(capsys, monkeypatch):
43
+ import cppcheck
44
+
45
+ monkeypatch.setenv("CPPCHECK_WHEEL_VERBOSE", "1")
46
+ # need to clear cache to make sure the function is run again
47
+ cppcheck._get_executable.cache_clear()
48
+ cppcheck.get_executable("cppcheck")
49
+ assert capsys.readouterr().out
50
+
51
+
52
+ def test_cppcheck():
53
+ import cppcheck
54
+
55
+ with tempfile.TemporaryDirectory() as tmpdir:
56
+ compilation_unit = Path(tmpdir) / "dummy.cpp"
57
+ with open(compilation_unit, "w") as ostr:
58
+ ostr.write("int main() { return 0;}\n")
59
+
60
+ # Verify that the addon and library files can be found.
61
+ xml_path = Path(tmpdir) / "report.xml"
62
+ assert (
63
+ cppcheck._run(
64
+ "cppcheck",
65
+ "--enable=all",
66
+ "--addon=naming",
67
+ "--library=std",
68
+ "--xml",
69
+ f"--output-file={xml_path!s}",
70
+ str(compilation_unit),
71
+ )
72
+ == 0
73
+ )
74
+
75
+ assert (
76
+ cppcheck._run_python(
77
+ "cppcheck-htmlreport",
78
+ f"--file={xml_path!s}",
79
+ f"--report-dir={tmpdir}/html",
80
+ )
81
+ == 0
82
+ )