summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/reflex/default.nix
blob: 49f29978690dfb7e7827016604677dc815524dc4 (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
143
144
145
146
147
148
149
150
151
152
153
154
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  pythonAtLeast,

  # build-system
  hatchling,
  pre-commit,
  toml,

  # dependencies
  alembic,
  click,
  granian,
  httpx,
  packaging,
  platformdirs,
  psutil,
  pydantic,
  python-multipart,
  python-socketio,
  redis,
  reflex-hosting-cli,
  rich,
  sqlmodel,
  starlette,
  typing-extensions,
  wrapt,

  # tests
  attrs,
  numpy,
  pandas,
  pillow,
  playwright,
  plotly,
  pytest-asyncio,
  pytest-mock,
  pytestCheckHook,
  python-dotenv,
  ruff,
  starlette-admin,
  unzip,
  uvicorn,
  versionCheckHook,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "reflex";
  version = "0.8.25";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "reflex-dev";
    repo = "reflex";
    tag = "v${finalAttrs.version}";
    hash = "sha256-pp4onogav+kad0JpBRPnar30elP1aYuhA9AMoSjjRss=";
  };

  # For some reason, pre_commit is supposedly missing when python>=3.14
  postPatch = lib.optionalString (pythonAtLeast "3.14") ''
    substituteInPlace pyproject.toml \
      --replace-fail '"pre_commit", ' ""
  '';

  build-system = [
    hatchling
    pre-commit
    toml
  ];

  dependencies = [
    alembic
    click
    granian
    httpx
    packaging
    platformdirs
    psutil
    pydantic
    python-multipart
    python-socketio
    redis
    reflex-hosting-cli
    rich
    sqlmodel
    starlette
    typing-extensions
    wrapt
  ]
  ++ granian.optional-dependencies.reload;

  nativeCheckInputs = [
    attrs
    numpy
    pandas
    pillow
    playwright
    plotly
    pytest-asyncio
    pytest-mock
    pytestCheckHook
    python-dotenv
    ruff
    starlette-admin
    unzip
    uvicorn
    versionCheckHook
    writableTmpDirAsHomeHook
  ];
  versionCheckProgramArg = "--version";

  disabledTests = [
    # Tests touch network
    "test_find_and_check_urls"
    "test_event_actions"
    "test_upload_file"
    "test_node_version"
    # /proc is too funky in nix sandbox
    "test_get_cpu_info"
    # flaky
    "test_preprocess" # KeyError: 'reflex___state____state'
    "test_send" # AssertionError: Expected 'post' to have been called once. Called 0 times.
    # tries to pin the string of a traceback, doesn't account for ansi colors
    "test_state_with_invalid_yield"
    # tries to run bun or npm
    "test_output_system_info"
    # Comparison with magic string
    "test_background_task_no_block"
    # reflex.utils.exceptions.StateSerializationError: Failed to serialize state
    # reflex___istate___dynamic____dill_state due to unpicklable object.
    "test_fallback_pickle"
  ];

  disabledTestPaths = [
    "tests/benchmarks/"
    "tests/integration/"
  ];

  __darwinAllowLocalNetworking = true;

  pythonImportsCheck = [ "reflex" ];

  meta = {
    description = "Web apps in pure Python";
    homepage = "https://github.com/reflex-dev/reflex";
    changelog = "https://github.com/reflex-dev/reflex/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ pbsds ];
    mainProgram = "reflex";
  };
})