1{ lib, python3Packages, fetchFromGitHub, fetchpatch }:
2
3python3Packages.buildPythonApplication rec {
4 pname = "cpplint";
5 version = "1.5.5";
6 format = "setuptools";
7
8 # Fetch from github instead of pypi, since the test cases are not in the pypi archive
9 src = fetchFromGitHub {
10 owner = pname;
11 repo = pname;
12 rev = version;
13 hash = "sha256-JXz2Ufo7JSceZVqYwCRkuAsOR08znZlIUk8GCLAyiI4=";
14 };
15
16 patches = [
17 ./0001-Remove-pytest-runner-version-pin.patch
18
19 # The patch below stops using the sre_compile module, which was deprecated
20 # in Python 3.11 and replaces it with re.compile. Upstream is unsure if it
21 # should use re.compile or re._compiler.compile, so we should monitor the
22 # thread for updates.
23 #
24 # https://github.com/cpplint/cpplint/pull/214
25 #
26 (fetchpatch {
27 name = "python-3.11-compatibility.patch";
28 url = "https://github.com/cpplint/cpplint/commit/e84e84f53915ae2a9214e756cf89c573a73bbcd3.patch";
29 hash = "sha256-u57AFWaVmGFSsvSGq1x9gZmTsuZPqXvTC7mTfyb2164=";
30 })
31 ];
32
33 postPatch = ''
34 patchShebangs cpplint_unittest.py
35 '';
36
37 nativeCheckInputs = with python3Packages; [ pytest pytest-runner ];
38 checkPhase = ''
39 ./cpplint_unittest.py
40 '';
41
42 meta = with lib; {
43 homepage = "https://github.com/cpplint/cpplint";
44 description = "Static code checker for C++";
45 maintainers = [ maintainers.bhipple ];
46 license = [ licenses.bsd3 ];
47 };
48}