about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/django-silk/default.nix
blob: 9f91aee935acd574f50df0dbd06091212421d5a5 (plain) (blame)
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
{ lib
, autopep8
, buildPythonPackage
, django
, factory-boy
, fetchFromGitHub
, fetchpatch
, freezegun
, gprof2dot
, jinja2
, mock
, networkx
, pillow
, pydot
, pygments
, python
, python-dateutil
, pythonOlder
, pytz
, requests
, setuptools-scm
, simplejson
, sqlparse
}:

buildPythonPackage rec {
  pname = "django-silk";
  version = "5.0.3";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "jazzband";
    repo = "django-silk";
    rev = "refs/tags/${version}";
    hash = "sha256-91FcOqAYZK7/RCKgXjbQEPUQ2cZRFi7NzVLQF+MMDRI=";
  };

  # "test_time_taken" tests aren't suitable for reproducible execution, but Django's
  # test runner doesn't have an easy way to ignore tests - so instead prevent it from picking
  # them up as tests
  postPatch = ''
    substituteInPlace project/tests/test_silky_profiler.py \
      --replace "def test_time_taken" "def _test_time_taken"
    substituteInPlace setup.py \
      --replace 'use_scm_version=True' 'version="${version}"'
  '';

  nativeBuildInputs = [
    setuptools-scm
  ];

  buildInputs = [
    mock
  ];

  propagatedBuildInputs = [
    autopep8
    django
    gprof2dot
    jinja2
    pillow
    pygments
    python-dateutil
    pytz
    requests
    simplejson
    sqlparse
  ];

  nativeCheckInputs = [
    freezegun
    networkx
    pydot
    factory-boy
  ];

  pythonImportsCheck = [
    "silk"
  ];

  checkPhase = ''
    runHook preCheck

    pushd project
    DB_ENGINE=sqlite3 DB_NAME=':memory:' ${python.interpreter} manage.py test
    popd # project

    runHook postCheck
  '';

  meta = with lib; {
    description = "Silky smooth profiling for the Django Framework";
    homepage = "https://github.com/jazzband/django-silk";
    changelog = "https://github.com/jazzband/django-silk/blob/${version}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ ris ];
  };
}