1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 alembic,
6 attrs,
7 build,
8 ruff,
9 dill,
10 granian,
11 hatchling,
12 httpx,
13 numpy,
14 packaging,
15 pandas,
16 pillow,
17 platformdirs,
18 playwright,
19 plotly,
20 psutil,
21 pydantic,
22 pytest-asyncio,
23 pytest-mock,
24 python-dotenv,
25 pytestCheckHook,
26 python-multipart,
27 python-socketio,
28 redis,
29 reflex-hosting-cli,
30 rich,
31 sqlmodel,
32 starlette-admin,
33 stdenv,
34 typer,
35 typing-extensions,
36 unzip,
37 uvicorn,
38 versionCheckHook,
39 wrapt,
40 writableTmpDirAsHomeHook,
41}:
42
43buildPythonPackage rec {
44 pname = "reflex";
45 version = "0.8.12";
46 pyproject = true;
47
48 src = fetchFromGitHub {
49 owner = "reflex-dev";
50 repo = "reflex";
51 tag = "v${version}";
52 hash = "sha256-NNjabOL5ls5aUaM+KiyLRwrkh2nAnwMYwDsd+jIsGLc=";
53 };
54
55 # 'rich' is also somehow checked when building the wheel,
56 # pythonRelaxDepsHook modifies the wheel METADATA in postBuild
57 pypaBuildFlags = [ "--skip-dependency-check" ];
58
59 pythonRelaxDeps = [
60 # needed
61 "click"
62 "starlette"
63 "rich"
64 ];
65
66 build-system = [ hatchling ];
67
68 dependencies = [
69 alembic
70 build # used in custom_components/custom_components.py
71 dill # used in state.py
72 granian
73 granian.optional-dependencies.reload
74 httpx
75 packaging # used in utils/prerequisites.py
76 platformdirs
77 psutil
78 pydantic
79 python-multipart
80 python-socketio
81 redis
82 reflex-hosting-cli
83 rich
84 sqlmodel
85 typer # optional dep
86 typing-extensions
87 wrapt
88 ];
89
90 nativeCheckInputs = [
91 pytestCheckHook
92 pytest-asyncio
93 pytest-mock
94 python-dotenv
95 ruff
96 playwright
97 attrs
98 numpy
99 plotly
100 pandas
101 pillow
102 unzip
103 uvicorn
104 starlette-admin
105 writableTmpDirAsHomeHook
106 versionCheckHook
107 ];
108 versionCheckProgramArg = "--version";
109
110 disabledTests = [
111 # Tests touch network
112 "test_find_and_check_urls"
113 "test_event_actions"
114 "test_upload_file"
115 "test_node_version"
116 # /proc is too funky in nix sandbox
117 "test_get_cpu_info"
118 # flaky
119 "test_preprocess" # KeyError: 'reflex___state____state'
120 "test_send" # AssertionError: Expected 'post' to have been called once. Called 0 times.
121 # tries to pin the string of a traceback, doesn't account for ansi colors
122 "test_state_with_invalid_yield"
123 # tries to run bun or npm
124 "test_output_system_info"
125 # Comparison with magic string
126 "test_background_task_no_block"
127 ]
128 ++ lib.optionals stdenv.hostPlatform.isDarwin [
129 # PermissionError: [Errno 1] Operation not permitted (fails in sandbox)
130 "test_is_process_on_port_free_port"
131 "test_is_process_on_port_occupied_port"
132 "test_is_process_on_port_both_protocols"
133 "test_is_process_on_port_concurrent_access"
134 ];
135
136 disabledTestPaths = [
137 "tests/benchmarks/"
138 "tests/integration/"
139 ];
140
141 pythonImportsCheck = [ "reflex" ];
142
143 meta = {
144 description = "Web apps in pure Python";
145 homepage = "https://github.com/reflex-dev/reflex";
146 changelog = "https://github.com/reflex-dev/reflex/releases/tag/${src.tag}";
147 license = lib.licenses.asl20;
148 maintainers = with lib.maintainers; [ pbsds ];
149 mainProgram = "reflex";
150 };
151}