summary refs log tree commit diff
path: root/pkgs/development/python-modules/ipython-sql/default.nix
blob: 2fc59859ab2a6c2a14b50f7ec3dec6f793d14ce4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, ipython
, ipython-genutils
, pandas
, prettytable
, pytest
, sqlalchemy
, sqlparse
}:
buildPythonPackage rec {
  pname = "ipython-sql";
  version = "0.4.0";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "catherinedevlin";
    repo = "ipython-sql";
    rev = "117764caf099d80100ed4b09fc004b55eed6f121";
    hash = "sha256-ScQihsvRSnC7VIgy8Tzi1z4x6KIZo0SAeLPvHAVdrfA=";
  };

  postPatch = ''
    substituteInPlace setup.py --replace 'prettytable<1' prettytable
  '';

  propagatedBuildInputs = [
    ipython
    ipython-genutils
    prettytable
    sqlalchemy
    sqlparse
  ];

  nativeCheckInputs = [ ipython pandas pytest ];

  checkPhase = ''
    runHook preCheck

    # running with ipython is required because the tests use objects available
    # only inside of ipython, for example the global `get_ipython()` function
    ipython -c 'import pytest; pytest.main()'

    runHook postCheck
  '';

  pythonImportsCheck = [ "sql" ];

  meta = with lib; {
    description = "Introduces a %sql (or %%sql) magic.";
    homepage = "https://github.com/catherinedevlin/ipython-sql";
    license = licenses.mit;
    maintainers = with maintainers; [ cpcloud ];
  };
}