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