1{ stdenv
2, buildPythonPackage
3, python
4, fetchFromGitHub
5, django
6, pygments
7, simplejson
8, dateutil
9, requests
10, sqlparse
11, jinja2
12, autopep8
13, pytz
14, pillow
15, mock
16, gprof2dot
17, freezegun
18, contextlib2
19, networkx
20, pydot
21, factory_boy
22}:
23
24buildPythonPackage rec {
25 pname = "django-silk";
26 version = "4.0.1";
27
28 # pypi tarball doesn't include test project
29 src = fetchFromGitHub {
30 owner = "jazzband";
31 repo = "django-silk";
32 rev = version;
33 sha256 = "0yy9rzxvwlp2xvnw76r9hnqajlp417snam92xpb6ay0hxwslwqyb";
34 };
35 # "test_time_taken" tests aren't suitable for reproducible execution, but django's
36 # test runner doesn't have an easy way to ignore tests - so instead prevent it from picking
37 # them up as tests
38 postPatch = ''
39 substituteInPlace project/tests/test_silky_profiler.py \
40 --replace "def test_time_taken" "def _test_time_taken"
41 substituteInPlace setup.py \
42 --replace 'use_scm_version=True' 'version="${version}"'
43 '';
44
45 buildInputs = [ mock ];
46 propagatedBuildInputs = [
47 django pygments simplejson dateutil requests
48 sqlparse jinja2 autopep8 pytz pillow gprof2dot
49 ];
50
51 checkInputs = [ freezegun contextlib2 networkx pydot factory_boy ];
52 checkPhase = ''
53 cd project
54 DB=sqlite3 DB_NAME=db.sqlite3 ${python.interpreter} manage.py test
55 '';
56
57 meta = with stdenv.lib; {
58 description = "Silky smooth profiling for the Django Framework";
59 homepage = "https://github.com/jazzband/django-silk";
60 license = licenses.mit;
61 maintainers = with maintainers; [ ris ];
62 };
63
64}