summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/psycopg2cffi/default.nix
blob: 8f361c109dee45a1e1ead6479329b37525d77bf1 (plain)
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
{
  buildPythonPackage,
  cffi,
  fetchFromGitHub,
  lib,
  libpq,
  postgresql,
  postgresqlTestHook,
  pytestCheckHook,
  setuptools,
  six,
  stdenv,
}:

buildPythonPackage rec {
  pname = "psycopg2cffi";
  version = "2.9.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "chtd";
    repo = "psycopg2cffi";
    tag = version;
    hash = "sha256-9r5MYxw9cvdbLVj8StmMmn0AKQepOpCc7TIBGXZGWe4=";
  };

  postPatch = ''
    substituteInPlace psycopg2cffi/_impl/_build_libpq.py \
      --replace-fail "from distutils import sysconfig" "import sysconfig" \
      --replace-fail "sysconfig.get_python_inc()" "sysconfig.get_path('include')"
  '';

  buildInputs = [ libpq ];
  nativeBuildInputs = [ libpq.pg_config ];

  build-system = [
    setuptools
  ];

  dependencies = [
    cffi
    six
  ];

  # FATAL: could not create shared memory segment: Operation not permitted
  doCheck = !stdenv.hostPlatform.isDarwin;

  nativeCheckInputs = [
    postgresql
    postgresqlTestHook
    pytestCheckHook
  ];

  disabledTests = [
    # AssertionError: '{}' != []
    "testEmptyArray"
  ];

  env = {
    PGDATABASE = "psycopg2_test";
  };

  pythonImportsCheck = [ "psycopg2cffi" ];

  meta = {
    description = "Implementation of the psycopg2 module using cffi";
    homepage = "https://pypi.org/project/psycopg2cffi/";
    license = with lib.licenses; [ lgpl3Plus ];
    maintainers = with lib.maintainers; [ lovesegfault ];
  };
}