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 pname version src;
35 hash = "sha256-9Vap8E71TkBIf4eIB2lapUqcMukdsHX4LR7U8AD77SU=";
36 };
37
38 pythonImportsCheck = [ "fastcrc" ];
39
40 nativeCheckInputs = [
41 pytestCheckHook
42 pytest-benchmark
43 ];
44
45 pytestFlags = [ "--benchmark-disable" ];
46
47 # Python source files interfere with testing
48 preCheck = ''
49 rm -r fastcrc
50 '';
51
52 passthru.updateScript = nix-update-script { };
53
54 meta = {
55 description = "Hyper-fast Python module for computing CRC(8, 16, 32, 64) checksum";
56 homepage = "https://fastcrc.readthedocs.io/en/latest/";
57 license = lib.licenses.mit;
58 maintainers = with lib.maintainers; [ pluiedev ];
59 };
60}