1{
2 stdenv,
3 lib,
4 buildPythonPackage,
5 fetchFromGitHub,
6 django,
7 pytestCheckHook,
8 setuptools,
9 celery,
10 django-taggit,
11 feedgen,
12 reportlab,
13 jsonschema,
14 wand,
15 django-filter,
16 django-treebeard,
17 djangorestframework,
18 pikepdf,
19 pypdf,
20 pycryptodome,
21 python-poppler,
22 zipstream-ng,
23 django-json-widget,
24 factory-boy,
25 pytest-django,
26 camelot,
27 pytesseract,
28 pytest-factoryboy,
29 poppler-utils,
30 pytest-playwright,
31 playwright-driver,
32 pnpm,
33 nodejs,
34 markdown,
35 nh3,
36}:
37
38buildPythonPackage rec {
39 pname = "django-filingcabinet";
40 version = "0.17-unstable-2025-04-10";
41 pyproject = true;
42
43 src = fetchFromGitHub {
44 owner = "okfde";
45 repo = "django-filingcabinet";
46 # No release tagged yet on GitHub
47 # https://github.com/okfde/django-filingcabinet/issues/69
48 rev = "64b7b4ad804067e2f16e8a0f165c139e3ffe5fb5";
49 hash = "sha256-48Peui/5N/GfzWS1EJ5uKeKEoPjX+fPEXzG2owxsDaE=";
50 };
51
52 postPatch = ''
53 # zipstream is discontinued and outdated
54 # https://github.com/okfde/django-filingcabinet/issues/90
55 substituteInPlace pyproject.toml \
56 --replace-fail "zipstream" "zipstream-ng"
57 '';
58
59 build-system = [ setuptools ];
60
61 nativeBuildInputs = [
62 nodejs
63 pnpm.configHook
64 ];
65
66 dependencies = [
67 celery
68 django
69 django-filter
70 django-json-widget
71 django-taggit
72 django-treebeard
73 djangorestframework
74 feedgen
75 jsonschema
76 markdown
77 nh3
78 pikepdf
79 pycryptodome
80 pypdf
81 python-poppler
82 reportlab
83 wand
84 zipstream-ng
85 ];
86
87 optional-dependencies = {
88 tabledetection = [ camelot ];
89 ocr = [ pytesseract ];
90 # Dependencies not yet packaged
91 #webp = [ webp ];
92 #annotate = [ fcdocs-annotate ];
93 };
94
95 pnpmDeps = pnpm.fetchDeps {
96 inherit pname version src;
97 hash = "sha256-uMO2iEOi9ACYdIM8Thf7+y1KpHQEqVxO3yxZ8RaGFXA=";
98 };
99
100 postBuild = ''
101 pnpm run build
102 '';
103
104 postInstall = ''
105 cp -r build $out/
106 '';
107
108 nativeCheckInputs = [
109 poppler-utils
110 pytest-django
111 pytest-factoryboy
112 pytest-playwright
113 pytestCheckHook
114 ];
115
116 disabledTests = [
117 # AssertionError: Locator expected to be visible
118 "test_keyboard_scroll"
119 "test_number_input_scroll"
120 # playwright._impl._errors.TimeoutError: Locator.click: Timeout 30000ms exceeded
121 "test_sidebar_hide"
122 "test_show_search_bar"
123 # Unable to launch browser
124 "test_document_viewer"
125 ];
126
127 preCheck =
128 ''
129 export DJANGO_SETTINGS_MODULE="test_project.settings"
130 ''
131 + lib.optionalString (!stdenv.hostPlatform.isRiscV) ''
132 export PLAYWRIGHT_BROWSERS_PATH="${playwright-driver.browsers}"
133 '';
134
135 pythonImportsCheck = [ "filingcabinet" ];
136
137 # Playwright tests not supported on RiscV yet
138 doCheck = lib.meta.availableOn stdenv.hostPlatform playwright-driver.browsers;
139
140 meta = {
141 description = "Django app that manages documents with pages, annotations and collections";
142 homepage = "https://github.com/okfde/django-filingcabinet";
143 changelog = "https://github.com/feincms/django-cabinet/blob/${version}/CHANGELOG.rst";
144 license = lib.licenses.mit;
145 maintainers = [ lib.maintainers.onny ];
146 };
147}