1{
2 buildPythonPackage,
3 cffi,
4 fetchFromGitHub,
5 lib,
6 postgresql,
7 postgresqlTestHook,
8 pytestCheckHook,
9 setuptools,
10 six,
11 stdenv,
12}:
13
14buildPythonPackage rec {
15 pname = "psycopg2cffi";
16 version = "2.9.0";
17 pyproject = true;
18
19 src = fetchFromGitHub {
20 owner = "chtd";
21 repo = "psycopg2cffi";
22 rev = "refs/tags/${version}";
23 hash = "sha256-9r5MYxw9cvdbLVj8StmMmn0AKQepOpCc7TIBGXZGWe4=";
24 };
25
26 postPatch = ''
27 substituteInPlace psycopg2cffi/_impl/_build_libpq.py \
28 --replace-fail "from distutils import sysconfig" "import sysconfig" \
29 --replace-fail "sysconfig.get_python_inc()" "sysconfig.get_path('include')"
30 '';
31
32 build-system = [
33 postgresql
34 setuptools
35 ];
36
37 dependencies = [
38 cffi
39 six
40 ];
41
42 # FATAL: could not create shared memory segment: Operation not permitted
43 doCheck = !stdenv.isDarwin;
44
45 nativeCheckInputs = [
46 postgresqlTestHook
47 pytestCheckHook
48 ];
49
50 disabledTests = [
51 # AssertionError: '{}' != []
52 "testEmptyArray"
53 ];
54
55 env = {
56 PGDATABASE = "psycopg2_test";
57 };
58
59 pythonImportsCheck = [ "psycopg2cffi" ];
60
61 meta = with lib; {
62 description = "An implementation of the psycopg2 module using cffi";
63 homepage = "https://pypi.org/project/psycopg2cffi/";
64 license = with licenses; [ lgpl3Plus ];
65 maintainers = with maintainers; [ lovesegfault ];
66 };
67}