1{ lib
2, blinker
3, buildPythonPackage
4, django
5, fetchFromGitHub
6, flake8
7, flask-sqlalchemy
8, isPy27
9, mock
10, peewee
11, pytest-django
12, pytestCheckHook
13, six
14, sqlalchemy
15, webtest
16}:
17
18buildPythonPackage rec {
19 pname = "nplusone";
20 version = "1.0.0";
21 disabled = isPy27;
22
23 src = fetchFromGitHub {
24 owner = "jmcarp";
25 repo = "nplusone";
26 rev = "v${version}";
27 sha256 = "0qdwpvvg7dzmksz3vqkvb27n52lq5sa8i06m7idnj5xk2dgjkdxg";
28 };
29
30 propagatedBuildInputs = [
31 blinker
32 six
33 ];
34
35 nativeCheckInputs = [
36 flake8
37 flask-sqlalchemy
38 mock
39 peewee
40 pytest-django
41 pytestCheckHook
42 sqlalchemy
43 webtest
44 ];
45
46 # The tests assume the source code is in an nplusone/ directory. When using
47 # the Nix sandbox, it will be in a source/ directory instead, making the
48 # tests fail.
49 prePatch = ''
50 substituteInPlace tests/conftest.py \
51 --replace nplusone/tests/conftest source/tests/conftest
52 '';
53
54 postPatch = ''
55 substituteInPlace pytest.ini \
56 --replace "python_paths" "pythonpath" \
57 --replace "--cov nplusone --cov-report term-missing" ""
58 '';
59
60 disabledTests = [
61 # Tests are out-dated
62 "test_many_to_one"
63 "test_many_to_many"
64 "test_eager_join"
65 "test_eager_subquery"
66 "test_eager_subquery_unused"
67 "test_many_to_many_raise"
68 "test_many_to_many_whitelist_decoy"
69 "test_many_to_one_subquery"
70 "test_many_to_one_reverse_subquery"
71 "test_many_to_many_subquery"
72 "test_many_to_many_reverse_subquery"
73 "test_profile"
74 ];
75
76 pythonImportsCheck = [ "nplusone" ];
77
78 meta = with lib; {
79 description = "Detecting the n+1 queries problem in Python";
80 homepage = "https://github.com/jmcarp/nplusone";
81 maintainers = with maintainers; [ cript0nauta ];
82 license = licenses.mit;
83 broken = lib.versionAtLeast django.version "4";
84 };
85}