1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitLab,
5 setuptools,
6 setuptools-scm,
7 cffi,
8 pytestCheckHook,
9 pytest-mock,
10 pkgs, # only for cmph
11}:
12
13buildPythonPackage rec {
14 pname = "swh-perfecthash";
15 version = "1.3.2";
16 pyproject = true;
17
18 src = fetchFromGitLab {
19 domain = "gitlab.softwareheritage.org";
20 group = "swh";
21 owner = "devel";
22 repo = "swh-perfecthash";
23 tag = "v${version}";
24 hash = "sha256-cG0h0lfSSooA7Mzrlsi5yIcbkbxQZ7mI5NtiB7D5Crs=";
25 };
26
27 build-system = [
28 setuptools
29 setuptools-scm
30 ];
31
32 dependencies = [
33 cffi
34 pkgs.cmph
35 ];
36
37 # The installed library clashes with the `swh` directory remaining in the source path.
38 # Usually, we get around this by `rm -rf` the python source files to ensure that the installed package is used.
39 # Here, we cannot do that as it would also remove the tests which are also in the `swh` directory.
40 preCheck = ''
41 rm -rf swh/perfecthash/*.py
42 '';
43
44 pythonImportsCheck = [ "swh.perfecthash" ];
45
46 nativeCheckInputs = [
47 pytestCheckHook
48 pytest-mock
49 ];
50
51 disabledTests = [
52 # Flake tests
53 "test_build_speed"
54 ];
55
56 meta = {
57 description = "Perfect hash table for software heritage object storage";
58 homepage = "https://gitlab.softwareheritage.org/swh/devel/swh-perfecthash";
59 license = lib.licenses.gpl3Only;
60 maintainers = with lib.maintainers; [ ];
61 };
62}