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