1{ lib
2, autopep8
3, buildPythonPackage
4, django
5, factory-boy
6, fetchFromGitHub
7, fetchpatch
8, freezegun
9, gprof2dot
10, jinja2
11, mock
12, networkx
13, pillow
14, pydot
15, pygments
16, python
17, python-dateutil
18, pythonOlder
19, pytz
20, requests
21, setuptools-scm
22, simplejson
23, sqlparse
24}:
25
26buildPythonPackage rec {
27 pname = "django-silk";
28 version = "5.0.3";
29 format = "setuptools";
30
31 disabled = pythonOlder "3.7";
32
33 src = fetchFromGitHub {
34 owner = "jazzband";
35 repo = "django-silk";
36 rev = "refs/tags/${version}";
37 hash = "sha256-91FcOqAYZK7/RCKgXjbQEPUQ2cZRFi7NzVLQF+MMDRI=";
38 };
39
40 # "test_time_taken" tests aren't suitable for reproducible execution, but Django's
41 # test runner doesn't have an easy way to ignore tests - so instead prevent it from picking
42 # them up as tests
43 postPatch = ''
44 substituteInPlace project/tests/test_silky_profiler.py \
45 --replace "def test_time_taken" "def _test_time_taken"
46 substituteInPlace setup.py \
47 --replace 'use_scm_version=True' 'version="${version}"'
48 '';
49
50 nativeBuildInputs = [
51 setuptools-scm
52 ];
53
54 buildInputs = [
55 mock
56 ];
57
58 propagatedBuildInputs = [
59 autopep8
60 django
61 gprof2dot
62 jinja2
63 pillow
64 pygments
65 python-dateutil
66 pytz
67 requests
68 simplejson
69 sqlparse
70 ];
71
72 nativeCheckInputs = [
73 freezegun
74 networkx
75 pydot
76 factory-boy
77 ];
78
79 pythonImportsCheck = [
80 "silk"
81 ];
82
83 checkPhase = ''
84 runHook preCheck
85
86 pushd project
87 DB_ENGINE=sqlite3 DB_NAME=':memory:' ${python.interpreter} manage.py test
88 popd # project
89
90 runHook postCheck
91 '';
92
93 meta = with lib; {
94 description = "Silky smooth profiling for the Django Framework";
95 homepage = "https://github.com/jazzband/django-silk";
96 changelog = "https://github.com/jazzband/django-silk/blob/${version}/CHANGELOG.md";
97 license = licenses.mit;
98 maintainers = with maintainers; [ ris ];
99 };
100}