1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8 setuptools-scm,
9
10 # optional dependencies
11 asgiref,
12 blinker,
13 django,
14 fastapi,
15 flask,
16 sanic,
17
18 # tests
19 django-redis,
20 pytest-django,
21 httpx,
22 fakeredis,
23 jsonschema,
24 pytestCheckHook,
25 pytest-cov-stub,
26 pytest-mock,
27 redis,
28 redisTestHook,
29}:
30
31buildPythonPackage rec {
32 pname = "dockerflow";
33 version = "2024.04.2";
34 pyproject = true;
35
36 src = fetchFromGitHub {
37 owner = "mozilla-services";
38 repo = "python-dockerflow";
39 tag = version;
40 hash = "sha256-5Ov605FyhX+n6vFks2sdtviGqkrgDIMXpcvgqR85jmQ=";
41 };
42
43 build-system = [
44 setuptools
45 setuptools-scm
46 ];
47
48 optional-dependencies = {
49 django = [ django ];
50 flask = [
51 blinker
52 flask
53 ];
54 sanic = [ sanic ];
55 fastapi = [
56 asgiref
57 fastapi
58 ];
59 };
60
61 nativeCheckInputs = [
62 fakeredis
63 jsonschema
64 pytestCheckHook
65 pytest-cov-stub
66 pytest-mock
67 redis
68 redisTestHook
69
70 # django
71 django-redis
72 pytest-django
73
74 # fastapi
75 httpx
76 ]
77 ++ lib.flatten (lib.attrValues optional-dependencies);
78
79 disabledTests = [
80 # AssertionError: assert 'c7a05e2b-8a21-4255-a3ed-92cea1e74a62' is None
81 "test_mozlog_without_correlation_id_middleware"
82 ];
83
84 disabledTestPaths = [
85 # missing flask-redis dependency
86 "tests/flask/test_flask.py"
87 # missing sanic-redis dependency
88 "tests/sanic/test_sanic.py"
89 ];
90
91 preCheck = ''
92 export DJANGO_SETTINGS_MODULE=tests.django.settings
93 '';
94
95 pythonImportsCheck = [
96 "dockerflow"
97 ];
98
99 meta = {
100 changelog = "https://github.com/mozilla-services/python-dockerflow/releases/tag/${src.tag}";
101 description = "Python package to implement tools and helpers for Mozilla Dockerflow";
102 homepage = "https://github.com/mozilla-services/python-dockerflow";
103 license = lib.licenses.mpl20;
104 };
105}