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