1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 rustPlatform,
7 pytestCheckHook,
8 pytest-benchmark,
9 nix-update-script,
10}:
11let
12 pname = "fastcrc";
13 version = "0.3.2";
14
15 src = fetchFromGitHub {
16 owner = "overcat";
17 repo = "fastcrc";
18 tag = "v${version}";
19 hash = "sha256-yLrv/zqsjgygJAIJtztwxlm4s9o9EBVsCyx1jUXd7hA=";
20 };
21in
22buildPythonPackage {
23 inherit pname version src;
24 pyproject = true;
25
26 disabled = pythonOlder "3.7";
27
28 nativeBuildInputs = with rustPlatform; [
29 cargoSetupHook
30 maturinBuildHook
31 ];
32
33 cargoDeps = rustPlatform.fetchCargoVendor {
34 inherit src;
35 name = "${pname}-${version}";
36 hash = "sha256-9Vap8E71TkBIf4eIB2lapUqcMukdsHX4LR7U8AD77SU=";
37 };
38
39 pythonImportsCheck = [ "fastcrc" ];
40
41 nativeCheckInputs = [
42 pytestCheckHook
43 pytest-benchmark
44 ];
45
46 # Python source files interfere with testing
47 preCheck = ''
48 rm -r fastcrc
49 '';
50
51 passthru.updateScript = nix-update-script { };
52
53 meta = {
54 description = "Hyper-fast Python module for computing CRC(8, 16, 32, 64) checksum";
55 homepage = "https://fastcrc.readthedocs.io/en/latest/";
56 license = lib.licenses.mit;
57 maintainers = with lib.maintainers; [ pluiedev ];
58 };
59}