1{
2 lib,
3 autopep8,
4 buildPythonPackage,
5 django,
6 factory-boy,
7 fetchFromGitHub,
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.3.2";
29 format = "setuptools";
30
31 disabled = pythonOlder "3.9";
32
33 src = fetchFromGitHub {
34 owner = "jazzband";
35 repo = "django-silk";
36 tag = version;
37 hash = "sha256-+JOUpjKR0rx+4+hU/5gSov5nW2aj7HR+HYr5FPbUkSA=";
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 = [ setuptools-scm ];
51
52 buildInputs = [ mock ];
53
54 propagatedBuildInputs = [
55 autopep8
56 django
57 gprof2dot
58 jinja2
59 pillow
60 pygments
61 python-dateutil
62 pytz
63 requests
64 simplejson
65 sqlparse
66 ];
67
68 nativeCheckInputs = [
69 freezegun
70 networkx
71 pydot
72 factory-boy
73 ];
74
75 pythonImportsCheck = [ "silk" ];
76
77 checkPhase = ''
78 runHook preCheck
79
80 pushd project
81 DB_ENGINE=sqlite3 DB_NAME=':memory:' ${python.interpreter} manage.py test
82 popd # project
83
84 runHook postCheck
85 '';
86
87 meta = with lib; {
88 description = "Silky smooth profiling for the Django Framework";
89 homepage = "https://github.com/jazzband/django-silk";
90 changelog = "https://github.com/jazzband/django-silk/blob/${version}/CHANGELOG.md";
91 license = licenses.mit;
92 maintainers = with maintainers; [ ris ];
93 };
94}