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