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