1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitLab,
6 poetry-core,
7 dramatiq,
8 flask,
9 requests,
10 pytestCheckHook,
11 flask-migrate,
12 periodiq,
13 postgresql,
14 postgresqlTestHook,
15 psycopg2,
16}:
17
18buildPythonPackage {
19 pname = "flask-dramatiq";
20 version = "0.6.0";
21 format = "pyproject";
22
23 disabled = pythonOlder "3.6";
24
25 src = fetchFromGitLab {
26 owner = "bersace";
27 repo = "flask-dramatiq";
28 rev = "840209e9bf582b4dda468e8bba515f248f3f8534";
29 hash = "sha256-qjV1zyVzHPXMt+oUeGBdP9XVlbcSz2MF9Zygj543T4w=";
30 };
31
32 postPatch = ''
33 substituteInPlace pyproject.toml \
34 --replace 'poetry>=0.12' 'poetry-core' \
35 --replace 'poetry.masonry.api' 'poetry.core.masonry.api'
36
37 patchShebangs --build ./example.py
38
39 sed -i ./tests/unit/pytest.ini \
40 -e 's:--cov=flask_dramatiq::' \
41 -e 's:--cov-report=term-missing::'
42 '';
43
44 nativeBuildInputs = [ poetry-core ];
45
46 propagatedBuildInputs = [ dramatiq ];
47
48 nativeCheckInputs = [
49 pytestCheckHook
50 flask
51 requests
52 flask-migrate
53 periodiq
54 postgresql
55 postgresqlTestHook
56 psycopg2
57 ] ++ dramatiq.optional-dependencies.rabbitmq;
58
59 postgresqlTestSetupPost = ''
60 substituteInPlace config.py \
61 --replace 'SQLALCHEMY_DATABASE_URI = f"postgresql://{PGUSER}:{PGPASSWORD}@{PGHOST}/{PGDATABASE}"' \
62 "SQLALCHEMY_DATABASE_URI = \"postgresql://$PGUSER/$PGDATABASE?host=$PGHOST\""
63 python3 ./example.py db upgrade
64 '';
65
66 pytestFlagsArray = [
67 "-x"
68 "tests/func/"
69 "tests/unit"
70 ];
71
72 pythonImportsCheck = [ "flask_dramatiq" ];
73
74 # Does HTTP requests to localhost
75 disabledTests = [
76 "test_fast"
77 "test_other"
78 ];
79
80 meta = with lib; {
81 description = "Adds Dramatiq support to your Flask application";
82 homepage = "https://gitlab.com/bersace/flask-dramatiq";
83 license = licenses.bsd3;
84 maintainers = with maintainers; [ traxys ];
85 };
86}