Wolfgang Walther c8eb80c5c6
python3Packages.psycopg2{,cffi}: use libpq instead of postgresql
We don't need the whole server to link against. We still use it in the
checkPhase do run tests against, but this will later be replaced by a
test-only derivation of the server.
2025-03-01 12:33:20 +01:00

73 lines
1.4 KiB
Nix

{
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 ];
# To find pg_config
nativeBuildInputs = [ libpq ];
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 = with lib; {
description = "Implementation of the psycopg2 module using cffi";
homepage = "https://pypi.org/project/psycopg2cffi/";
license = with licenses; [ lgpl3Plus ];
maintainers = with maintainers; [ lovesegfault ];
};
}