summary refs log tree commit diff
path: root/pkgs/development/python-modules/schemainspect/default.nix
blob: 1703853f3c9251613b17848501e9dba06d9b7c81 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{ lib
, buildPythonPackage
, fetchFromGitHub
, fetchpatch
, pythonOlder
, sqlalchemy
, sqlbag
, setuptools
, poetry-core
, pytestCheckHook
, pytest-xdist
, pytest-sugar
, postgresql
, postgresqlTestHook
,
}:
buildPythonPackage rec {
  pname = "schemainspect";
  version = "3.1.1663587362";
  format = "pyproject";
  disable = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "djrobstep";
    repo = pname;
    # no tags on github, version patch number is unix time.
    rev = "066262d6fb4668f874925305a0b7dbb3ac866882";
    hash = "sha256-SYpQQhlvexNc/xEgSIk8L8J+Ta+3OZycGLeZGQ6DWzk=";
  };

  patches = [
    # https://github.com/djrobstep/schemainspect/pull/87
    (fetchpatch
      {
        name = "specify_poetry.patch";
        url = "https://github.com/djrobstep/schemainspect/commit/bdcd001ef7798236fe0ff35cef52f34f388bfe68.patch";
        hash = "sha256-/SEmcV9GjjvzfbszeGPkfd2DvYenl7bZyWdC0aI3M4M=";
      })
  ];

  nativeBuildInputs = [
    poetry-core
  ];
  propagatedBuildInputs = [
    setuptools # needed for 'pkg_resources'
    sqlalchemy
  ];

  nativeCheckInputs = [
    pytestCheckHook
    pytest-xdist
    pytest-sugar

    postgresql
    postgresqlTestHook

    sqlbag
  ];

  preCheck = ''
    export PGUSER="nixbld";
    export postgresqlEnableTCP=1;
  '';
  disabledTests = [
    # These all fail with "List argument must consist only of tuples or dictionaries":
    # Related issue: https://github.com/djrobstep/schemainspect/issues/88
    "test_can_replace"
    "test_collations"
    "test_constraints"
    "test_dep_order"
    "test_enum_deps"
    "test_exclusion_constraint"
    "test_fk_col_order"
    "test_fk_info"
    "test_generated_columns"
    "test_identity_columns"
    "test_indexes"
    "test_inherit"
    "test_kinds"
    "test_lineendings"
    "test_long_identifiers"
    "test_partitions"
    "test_postgres_inspect"
    "test_postgres_inspect_excludeschema"
    "test_postgres_inspect_sigleschema"
    "test_raw_connection"
    "test_relationship"
    "test_replica_trigger"
    "test_rls"
    "test_separate_validate"
    "test_sequences"
    "test_table_dependency_order"
    "test_types_and_domains"
    "test_view_trigger"
    "test_weird_names"
  ];

  pytestFlagsArray = [
    "-x"
    "-svv"
    "tests"
  ];
  pythonImportsCheck = [
    "schemainspect"
  ];

  postUnpack = ''
    # this dir is used to bump the version number, having it here fails the build
    rm -r ./source/deploy
  '';

  meta = with lib; {
    description = "Schema inspection for PostgreSQL, and potentially others";
    homepage = "https://github.com/djrobstep/schemainspect";
    license = with licenses; [ unlicense ];
    maintainers = with maintainers; [ soispha ];
  };
}