python3Packages.psycopg: package pool and c variants
Both implementations require the basic psycopg package and cannot exist without it. Therefore they have no global name within the python package set and are only accessible via psycopg's optional-dependencies.
This commit is contained in:
parent
e6d39fcc8f
commit
2f51f9b748
1 changed files with 101 additions and 29 deletions
|
@ -6,13 +6,17 @@
|
|||
, pythonOlder
|
||||
, substituteAll
|
||||
|
||||
# links (libpq)
|
||||
# build
|
||||
, postgresql
|
||||
, setuptools
|
||||
|
||||
# propagates
|
||||
, backports-zoneinfo
|
||||
, typing-extensions
|
||||
|
||||
# psycopg-c
|
||||
, cython_3
|
||||
|
||||
# docs
|
||||
, furo
|
||||
, shapely
|
||||
|
@ -29,13 +33,6 @@
|
|||
let
|
||||
pname = "psycopg";
|
||||
version = "3.0.16";
|
||||
in
|
||||
|
||||
buildPythonPackage {
|
||||
inherit pname version;
|
||||
format = "pyproject";
|
||||
|
||||
disabled = pythonOlder "3.7";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "psycopg";
|
||||
|
@ -44,6 +41,80 @@ buildPythonPackage {
|
|||
hash = "sha256-jKhpmCcDi7FyMSpn51eSukFvmu3yacNovmRYG9jnu3g=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./libpq.patch;
|
||||
libpq = "${postgresql.lib}/lib/libpq${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
})
|
||||
];
|
||||
|
||||
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 = [
|
||||
setuptools
|
||||
cython_3
|
||||
postgresql
|
||||
];
|
||||
|
||||
# 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
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = lib.optionals (pythonOlder "3.10") [
|
||||
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";
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"doc"
|
||||
|
@ -57,26 +128,24 @@ buildPythonPackage {
|
|||
hash = "sha256-yn09fR9+7zQni8SvTG7BUmYRD7MK7u2arVAznWz2oAw=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./libpq.patch;
|
||||
libpq = "${postgresql.lib}/lib/libpq${stdenv.hostPlatform.extensions.sharedLibrary}";
|
||||
})
|
||||
];
|
||||
inherit patches;
|
||||
|
||||
# only move to sourceRoot after patching, makes patching easier
|
||||
postPatch = ''
|
||||
cd ${pname}
|
||||
cd psycopg
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
furo
|
||||
setuptools
|
||||
shapely
|
||||
sphinxHook
|
||||
sphinx-autodoc-typehints
|
||||
sphinxHook
|
||||
];
|
||||
|
||||
propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [
|
||||
propagatedBuildInputs = [
|
||||
psycopg-c
|
||||
] ++ lib.optionals (pythonOlder "3.11") [
|
||||
typing-extensions
|
||||
] ++ lib.optionals (pythonOlder "3.9") [
|
||||
backports-zoneinfo
|
||||
|
@ -84,12 +153,13 @@ buildPythonPackage {
|
|||
|
||||
pythonImportsCheck = [
|
||||
"psycopg"
|
||||
"psycopg_c"
|
||||
"psycopg_pool"
|
||||
];
|
||||
|
||||
passthru.optional-dependencies = {
|
||||
# TODO: package remaining variants
|
||||
#c = [ psycopg-c ];
|
||||
#pool = [ psycopg-pool ];
|
||||
c = [ psycopg-c ];
|
||||
pool = [ psycopg-pool ];
|
||||
};
|
||||
|
||||
preCheck = ''
|
||||
|
@ -102,16 +172,17 @@ buildPythonPackage {
|
|||
pytest-randomly
|
||||
pytestCheckHook
|
||||
postgresql
|
||||
];
|
||||
]
|
||||
++ passthru.optional-dependencies.c
|
||||
++ passthru.optional-dependencies.pool;
|
||||
|
||||
disabledTests = [
|
||||
# linters shouldn't be run in checks
|
||||
# don't depend on mypy for tests
|
||||
"test_version"
|
||||
"test_package_version"
|
||||
];
|
||||
|
||||
disabledTestPaths = [
|
||||
# TODO: requires the pooled variant
|
||||
"tests/pool/"
|
||||
# Network access
|
||||
"tests/test_dns.py"
|
||||
"tests/test_dns_srv.py"
|
||||
|
@ -127,11 +198,12 @@ buildPythonPackage {
|
|||
cd ${pname}
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/psycopg/psycopg/blob/master/docs/news.rst";
|
||||
passthru = {
|
||||
c = psycopg-c;
|
||||
pool = psycopg-pool;
|
||||
};
|
||||
|
||||
meta = baseMeta // {
|
||||
description = "PostgreSQL database adapter for Python";
|
||||
homepage = "https://github.com/psycopg/psycopg";
|
||||
license = licenses.lgpl3Plus;
|
||||
maintainers = with maintainers; [ hexa ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue