summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/starlette-admin/default.nix
blob: 5c341d6d7a4a553df58489a2cd42ca3a894f3968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  pythonAtLeast,

  # build-system
  hatchling,

  # dependencies
  jinja2,
  python-multipart,
  starlette,

  # optional-dependencies
  babel,

  # tests
  aiosqlite,
  arrow,
  cacert,
  colour,
  fasteners,
  httpx,
  mongoengine,
  motor,
  passlib,
  phonenumbers,
  pillow,
  psycopg2,
  pydantic,
  pytest-asyncio,
  pytestCheckHook,
  requests,
  sqlalchemy,
  sqlalchemy-file,
  sqlalchemy-utils,
  sqlmodel,
}:

buildPythonPackage rec {
  pname = "starlette-admin";
  version = "0.16.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "jowilf";
    repo = "starlette-admin";
    tag = version;
    hash = "sha256-JVvrfbyKillkx6fOx4DEbHZoHIPxF1Gn3HzkxyJc66o=";
  };

  build-system = [ hatchling ];

  dependencies = [
    jinja2
    python-multipart
    starlette
  ];

  optional-dependencies = {
    i18n = [ babel ];
  };

  nativeCheckInputs = [
    aiosqlite
    arrow
    babel
    cacert
    colour
    fasteners
    httpx
    mongoengine
    motor
    passlib
    phonenumbers
    pillow
    psycopg2
    pydantic
    pytest-asyncio
    pytestCheckHook
    requests
    sqlalchemy
    sqlalchemy-file
    sqlalchemy-utils
    sqlmodel
  ];

  preCheck = ''
    # used in get_test_container in tests/sqla/utils.py
    # fixes FileNotFoundError: [Errno 2] No such file or directory: '/tmp/storage/...'
    mkdir .storage
    export LOCAL_PATH="$PWD/.storage"
  '';

  disabledTests =
    lib.optionals (pythonAtLeast "3.14") [
      # AssertionError: Regex pattern did not match
      "test_not_supported_annotation"
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      # flaky, depends on test order
      "test_ensuring_pk"
      # flaky, of-by-one
      "test_api"
    ];

  disabledTestPaths = [
    # odmantic is not packaged
    "tests/odmantic"
    # beanie is not packaged
    "tests/beanie"
    # needs mongodb running on port 27017
    "tests/mongoengine"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # very flaky, sandbox issues?
    # libcloud.storage.types.ContainerDoesNotExistError
    # sqlite3.OperationalError: attempt to write a readonly database
    "tests/sqla/test_sync_engine.py"
    "tests/sqla/test_async_engine.py"
  ];

  pythonImportsCheck = [
    "starlette_admin"
    "starlette_admin.actions"
    "starlette_admin.base"
    "starlette_admin.fields"
    "starlette_admin.i18n"
    "starlette_admin.tools"
    "starlette_admin.views"
  ];

  meta = {
    description = "Fast, beautiful and extensible administrative interface framework for Starlette & FastApi applications";
    homepage = "https://github.com/jowilf/starlette-admin";
    changelog = "https://jowilf.github.io/starlette-admin/changelog/";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ pbsds ];
  };
}