14 buildPythonPackage rec {
17 format = "setuptools";
19 # Extension modules don't work well with PyPy. Use psycopg2cffi instead.
20 # c.f. https://github.com/NixOS/nixpkgs/pull/104151#issuecomment-729750892
21 disabled = pythonOlder "3.6" || isPyPy;
23 outputs = [ "out" "doc" ];
26 inherit pname version;
27 hash = "sha256-8AzDW9cRnx/tF7hb0QB4VRlN3iy9jeAauOuxdIdECtg=";
31 # Preferably upstream would not depend on pg_config because config scripts are incompatible with cross-compilation, however postgresql's pc file is lacking information.
32 # some linker flags are added but the linker ignores them because they're incompatible
33 # https://github.com/psycopg/psycopg2/blob/89005ac5b849c6428c05660b23c5a266c96e677d/setup.py
34 substituteInPlace setup.py \
35 --replace "self.pg_config_exe = self.build_ext.pg_config" 'self.pg_config_exe = "${lib.getExe' buildPackages.postgresql "pg_config"}"'
45 ] ++ lib.optionals stdenv.isDarwin [
49 sphinxRoot = "doc/src";
51 # Requires setting up a PostgreSQL database
54 pythonImportsCheck = [
58 disallowedReferences = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ buildPackages.postgresql ];
61 description = "PostgreSQL database adapter for the Python programming language";
62 homepage = "https://www.psycopg.org";
63 license = with licenses; [ lgpl3Plus zpl20 ];
64 maintainers = with maintainers; [ ];