1{ lib
2, buildPythonPackage
3, fetchpatch
4, fetchFromGitHub
5, poetry-core
6, celery
7, redis
8, pytestCheckHook
9, pytest-celery
10}:
11
12buildPythonPackage rec {
13 pname = "celery-singleton";
14 version = "0.3.1";
15 format = "pyproject";
16
17 src = fetchFromGitHub {
18 owner = "steinitzu";
19 repo = "celery-singleton";
20 rev = version;
21 hash = "sha256-fHlakxxjYIADELZdxIj6rvsZ/+1QfnKvAg3w5cdzvDc=";
22 };
23
24 postPatch = ''
25 # Disable coverage reporting in tests
26 substituteInPlace setup.cfg \
27 --replace "--cov" "" \
28 --replace "--no-cov-on-fail" ""
29 '';
30
31 patches = [
32 # chore(poetry): use poetry-core
33 # https://github.com/steinitzu/celery-singleton/pull/54
34 (fetchpatch {
35 name = "use-poetry-core.patch";
36 url = "https://github.com/steinitzu/celery-singleton/pull/54/commits/634a001c92a1dff1fae513fc95d733ea9b87e4cf.patch";
37 hash = "sha256-lXN4khwyL96pWyBS+iuSkGEkegv4HxYtym+6JUcPa94=";
38 })
39 ];
40
41 nativeBuildInputs = [
42 poetry-core
43 ];
44
45 propagatedBuildInputs = [
46 celery
47 redis
48 ];
49
50 checkInputs = [
51 pytestCheckHook
52 pytest-celery
53 ];
54
55 pytestFlagsArray = [ "tests" ];
56
57 # Tests require a running Redis backend
58 disabledTests = [
59 "TestLock"
60 "TestUnlock"
61 "TestClear"
62 "TestSimpleTask"
63 "TestRaiseOnDuplicateConfig"
64 "TestUniqueOn"
65 ];
66
67 pythonImportsCheck = [ "celery_singleton" ];
68
69 meta = with lib; {
70 description = "Seamlessly prevent duplicate executions of celery tasks";
71 homepage = "https://github.com/steinitzu/celery-singleton";
72 changelog = "https://github.com/steinitzu/celery-singleton/blob/${src.rev}/CHANGELOG.md";
73 license = licenses.mit;
74 maintainers = with maintainers; [ onny ];
75 };
76}