about summary refs log tree commit diff
path: root/pkgs/development/python-modules/psycopg2cffi/default.nix
blob: 608bae034ea58cb045adc7a89d19b6a376ce9a7e (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
{ buildPythonPackage
, cffi
, fetchFromGitHub
, lib
, postgresql
, postgresqlTestHook
, pytestCheckHook
, setuptools
, six
, stdenv
}:

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

  src = fetchFromGitHub {
    owner = "chtd";
    repo = "psycopg2cffi";
    rev = "refs/tags/${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')"
  '';

  build-system = [
    postgresql
    setuptools
  ];

  dependencies = [
    cffi
    six
  ];

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

  nativeCheckInputs = [
    postgresqlTestHook
    pytestCheckHook
  ];

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

  env = {
    PGDATABASE = "psycopg2_test";
  };

  pythonImportsCheck = [ "psycopg2cffi" ];

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