1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 hatchling,
7 aiosqlite,
8 arrow,
9 babel,
10 cacert,
11 colour,
12 fasteners,
13 httpx,
14 jinja2,
15 mongoengine,
16 motor,
17 passlib,
18 phonenumbers,
19 pillow,
20 psycopg2,
21 pydantic,
22 pytest-asyncio,
23 pytestCheckHook,
24 python-multipart,
25 requests,
26 sqlalchemy,
27 sqlalchemy-file,
28 sqlalchemy-utils,
29 sqlmodel,
30 starlette,
31}:
32
33buildPythonPackage rec {
34 pname = "starlette-admin";
35 version = "0.14.1";
36 pyproject = true;
37
38 src = fetchFromGitHub {
39 owner = "jowilf";
40 repo = "starlette-admin";
41 rev = version;
42 hash = "sha256-DoYD8Hc5pd68+BhASw3mwwCdhu0vYHiELjVmVwU8FHs=";
43 };
44
45 build-system = [ hatchling ];
46
47 dependencies = [
48 jinja2
49 python-multipart
50 starlette
51 ];
52
53 optional-dependencies = {
54 i18n = [ babel ];
55 };
56
57 nativeCheckInputs = [
58 aiosqlite
59 arrow
60 babel
61 cacert
62 colour
63 fasteners
64 httpx
65 mongoengine
66 motor
67 passlib
68 phonenumbers
69 pillow
70 psycopg2
71 pydantic
72 pytest-asyncio
73 pytestCheckHook
74 requests
75 sqlalchemy
76 sqlalchemy-file
77 sqlalchemy-utils
78 sqlmodel
79 ];
80
81 preCheck = ''
82 # used in get_test_container in tests/sqla/utils.py
83 # fixes FileNotFoundError: [Errno 2] No such file or directory: '/tmp/storage/...'
84 mkdir .storage
85 export LOCAL_PATH="$PWD/.storage"
86 '';
87
88 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
89 # flaky, depends on test order
90 "test_ensuring_pk"
91 # flaky, of-by-one
92 "test_api"
93 ];
94
95 disabledTestPaths =
96 [
97 # odmantic is not packaged
98 "tests/odmantic"
99 # needs mongodb running on port 27017
100 "tests/mongoengine"
101 ]
102 ++ lib.optionals stdenv.hostPlatform.isDarwin [
103 # very flaky, sandbox issues?
104 # libcloud.storage.types.ContainerDoesNotExistError
105 # sqlite3.OperationalError: attempt to write a readonly database
106 "tests/sqla/test_sync_engine.py"
107 "tests/sqla/test_async_engine.py"
108 ];
109
110 pythonImportsCheck = [
111 "starlette_admin"
112 "starlette_admin.actions"
113 "starlette_admin.base"
114 "starlette_admin.fields"
115 "starlette_admin.i18n"
116 "starlette_admin.tools"
117 "starlette_admin.views"
118 ];
119
120 meta = with lib; {
121 description = "Fast, beautiful and extensible administrative interface framework for Starlette & FastApi applications";
122 homepage = "https://github.com/jowilf/starlette-admin";
123 changelog = "https://github.com/jowilf/starlette-admin/blob/${src.rev}/CHANGELOG.md";
124 license = licenses.mit;
125 maintainers = with maintainers; [ pbsds ];
126 };
127}