1{ blinker, buildPythonPackage, fetchFromGitHub, lib, isPy27, six, mock, pytest
2, webtest, pytestcov, pytest-django, pytest-pythonpath, flake8, sqlalchemy
3, flask_sqlalchemy, peewee }:
4
5buildPythonPackage rec {
6 pname = "nplusone";
7 version = "1.0.0";
8 disabled = isPy27;
9
10 src = fetchFromGitHub {
11 owner = "jmcarp";
12 repo = "nplusone";
13 rev = "v${version}";
14 sha256 = "0qdwpvvg7dzmksz3vqkvb27n52lq5sa8i06m7idnj5xk2dgjkdxg";
15 };
16
17 # The tests assume the source code is in an nplusone/ directory. When using
18 # the Nix sandbox, it will be in a source/ directory instead, making the
19 # tests fail.
20 prePatch = ''
21 substituteInPlace tests/conftest.py \
22 --replace nplusone/tests/conftest source/tests/conftest
23 '';
24
25 checkPhase = ''
26 pytest tests/
27 '';
28
29 propagatedBuildInputs = [ six blinker ];
30 checkInputs = [
31 mock
32 pytest
33 webtest
34 pytestcov
35 pytest-django
36 pytest-pythonpath
37 flake8
38 sqlalchemy
39 flask_sqlalchemy
40 peewee
41 ];
42
43 meta = with lib; {
44 description = "Detecting the n+1 queries problem in Python";
45 homepage = "https://github.com/jmcarp/nplusone";
46 maintainers = with maintainers; [ cript0nauta ];
47 license = licenses.mit;
48 };
49}