2022-08-12 12:06:08 +00:00
|
|
|
{ lib
|
2022-08-21 13:32:41 +00:00
|
|
|
, stdenv
|
2022-08-12 12:06:08 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
2023-04-12 12:48:02 +00:00
|
|
|
, fetchpatch
|
2022-08-12 12:06:08 +00:00
|
|
|
, fetchurl
|
|
|
|
, pythonOlder
|
|
|
|
, substituteAll
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
# build
|
2022-08-12 12:06:08 +00:00
|
|
|
, postgresql
|
2022-09-09 14:08:57 +00:00
|
|
|
, setuptools
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
# propagates
|
|
|
|
, backports-zoneinfo
|
|
|
|
, typing-extensions
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
# psycopg-c
|
|
|
|
, cython_3
|
2023-02-02 18:25:31 +00:00
|
|
|
, tomli
|
2022-09-09 14:08:57 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# docs
|
|
|
|
, furo
|
|
|
|
, shapely
|
|
|
|
, sphinxHook
|
|
|
|
, sphinx-autodoc-typehints
|
|
|
|
|
|
|
|
# tests
|
|
|
|
, pproxy
|
|
|
|
, pytest-asyncio
|
|
|
|
, pytest-randomly
|
|
|
|
, pytestCheckHook
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "psycopg";
|
2023-02-02 18:25:31 +00:00
|
|
|
version = "3.1.8";
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "psycopg";
|
|
|
|
repo = pname;
|
2022-09-09 14:08:57 +00:00
|
|
|
rev = "refs/tags/${version}";
|
2023-02-02 18:25:31 +00:00
|
|
|
hash = "sha256-VmuotHcLWd+k8/GLv0N2wSZR0sZjY+TmGBQjhpYE3YA=";
|
2022-08-12 12:06:08 +00:00
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./ctypes.patch;
|
|
|
|
libpq = "${postgresql.lib}/lib/libpq${stdenv.hostPlatform.extensions.sharedLibrary}";
|
|
|
|
libc = "${stdenv.cc.libc}/lib/libc.so.6";
|
|
|
|
})
|
2023-04-12 12:48:02 +00:00
|
|
|
(fetchpatch {
|
|
|
|
name = "cython-3.0.0b1-compat.patch";
|
|
|
|
url = "https://github.com/psycopg/psycopg/commit/573446a14312f36257ed9dcfb8eb2756b69d5d9b.patch";
|
|
|
|
hash = "sha256-NWItarNb/Yyfj1avb/SXTkinVGxvWUGH8y6tR/zhVmE=";
|
|
|
|
})
|
2022-09-09 14:08:57 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
baseMeta = {
|
|
|
|
changelog = "https://github.com/psycopg/psycopg/blob/master/docs/news.rst";
|
|
|
|
homepage = "https://github.com/psycopg/psycopg";
|
|
|
|
license = lib.licenses.lgpl3Plus;
|
|
|
|
maintainers = with lib.maintainers; [ hexa ];
|
|
|
|
};
|
|
|
|
|
|
|
|
psycopg-c = buildPythonPackage {
|
|
|
|
pname = "${pname}-c";
|
|
|
|
inherit version src;
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
# apply patches to base repo
|
|
|
|
inherit patches;
|
|
|
|
|
|
|
|
# move into source root after patching
|
|
|
|
postPatch = ''
|
|
|
|
cd psycopg_c
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cython_3
|
|
|
|
postgresql
|
2023-02-02 18:25:31 +00:00
|
|
|
setuptools
|
|
|
|
tomli
|
2022-09-09 14:08:57 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# tested in psycopg
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
meta = baseMeta // {
|
|
|
|
description = "C optimisation distribution for Psycopg";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
psycopg-pool = buildPythonPackage {
|
|
|
|
pname = "${pname}-pool";
|
|
|
|
inherit version src;
|
|
|
|
format = "setuptools";
|
|
|
|
|
|
|
|
# apply patches to base repo
|
|
|
|
inherit patches;
|
|
|
|
|
|
|
|
# move into source root after patching
|
|
|
|
postPatch = ''
|
|
|
|
cd psycopg_pool
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
propagatedBuildInputs = [
|
2022-09-09 14:08:57 +00:00
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
|
|
|
# tested in psycopg
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
meta = baseMeta // {
|
|
|
|
description = "Connection Pool for Psycopg";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
inherit pname version src;
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"doc"
|
|
|
|
];
|
|
|
|
|
|
|
|
sphinxRoot = "../docs";
|
|
|
|
|
|
|
|
# Introduce this file necessary for the docs build via environment var
|
|
|
|
LIBPQ_DOCS_FILE = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/postgres/postgres/REL_14_STABLE/doc/src/sgml/libpq.sgml";
|
|
|
|
hash = "sha256-yn09fR9+7zQni8SvTG7BUmYRD7MK7u2arVAznWz2oAw=";
|
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
inherit patches;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
# only move to sourceRoot after patching, makes patching easier
|
|
|
|
postPatch = ''
|
2022-09-09 14:08:57 +00:00
|
|
|
cd psycopg
|
2022-08-12 12:06:08 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
furo
|
2022-09-09 14:08:57 +00:00
|
|
|
setuptools
|
2022-08-12 12:06:08 +00:00
|
|
|
shapely
|
|
|
|
sphinx-autodoc-typehints
|
2022-09-09 14:08:57 +00:00
|
|
|
sphinxHook
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
psycopg-c
|
2022-08-12 12:06:08 +00:00
|
|
|
typing-extensions
|
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
|
|
|
backports-zoneinfo
|
|
|
|
];
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"psycopg"
|
2022-09-09 14:08:57 +00:00
|
|
|
"psycopg_c"
|
|
|
|
"psycopg_pool"
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
passthru.optional-dependencies = {
|
2022-09-09 14:08:57 +00:00
|
|
|
c = [ psycopg-c ];
|
|
|
|
pool = [ psycopg-pool ];
|
2022-08-12 12:06:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
cd ..
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-08-12 12:06:08 +00:00
|
|
|
pproxy
|
|
|
|
pytest-asyncio
|
|
|
|
pytest-randomly
|
|
|
|
pytestCheckHook
|
|
|
|
postgresql
|
2022-09-09 14:08:57 +00:00
|
|
|
]
|
|
|
|
++ passthru.optional-dependencies.c
|
|
|
|
++ passthru.optional-dependencies.pool;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
disabledTests = [
|
2022-09-09 14:08:57 +00:00
|
|
|
# don't depend on mypy for tests
|
2022-08-12 12:06:08 +00:00
|
|
|
"test_version"
|
2022-09-09 14:08:57 +00:00
|
|
|
"test_package_version"
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
disabledTestPaths = [
|
|
|
|
# Network access
|
|
|
|
"tests/test_dns.py"
|
|
|
|
"tests/test_dns_srv.py"
|
|
|
|
# Mypy typing test
|
|
|
|
"tests/test_typing.py"
|
2022-09-09 14:08:57 +00:00
|
|
|
"tests/crdb/test_typing.py"
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
pytestFlagsArray = [
|
2023-02-02 18:25:31 +00:00
|
|
|
"-o" "cache_dir=$TMPDIR"
|
|
|
|
"-m" "'not timing'"
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postCheck = ''
|
|
|
|
cd ${pname}
|
|
|
|
'';
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
passthru = {
|
|
|
|
c = psycopg-c;
|
|
|
|
pool = psycopg-pool;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = baseMeta // {
|
2022-08-12 12:06:08 +00:00
|
|
|
description = "PostgreSQL database adapter for Python";
|
|
|
|
};
|
|
|
|
}
|