Merge pull request #186632 from mweinelt/psycopg-c-pool

authored by Martin Weinelt and committed by GitHub e061560a 56fd857a

+105 -29
+105 -29
pkgs/development/python-modules/psycopg/default.nix
··· 6 6 , pythonOlder 7 7 , substituteAll 8 8 9 - # links (libpq) 9 + # build 10 10 , postgresql 11 + , setuptools 11 12 12 13 # propagates 13 14 , backports-zoneinfo 14 15 , typing-extensions 16 + 17 + # psycopg-c 18 + , cython_3 15 19 16 20 # docs 17 21 , furo ··· 29 33 let 30 34 pname = "psycopg"; 31 35 version = "3.0.16"; 32 - in 33 - 34 - buildPythonPackage { 35 - inherit pname version; 36 - format = "pyproject"; 37 - 38 - disabled = pythonOlder "3.7"; 39 36 40 37 src = fetchFromGitHub { 41 38 owner = "psycopg"; ··· 44 41 hash = "sha256-jKhpmCcDi7FyMSpn51eSukFvmu3yacNovmRYG9jnu3g="; 45 42 }; 46 43 44 + patches = [ 45 + (substituteAll { 46 + src = ./libpq.patch; 47 + libpq = "${postgresql.lib}/lib/libpq${stdenv.hostPlatform.extensions.sharedLibrary}"; 48 + }) 49 + ]; 50 + 51 + baseMeta = { 52 + changelog = "https://github.com/psycopg/psycopg/blob/master/docs/news.rst"; 53 + homepage = "https://github.com/psycopg/psycopg"; 54 + license = lib.licenses.lgpl3Plus; 55 + maintainers = with lib.maintainers; [ hexa ]; 56 + }; 57 + 58 + psycopg-c = buildPythonPackage { 59 + pname = "${pname}-c"; 60 + inherit version src; 61 + format = "pyproject"; 62 + 63 + # apply patches to base repo 64 + inherit patches; 65 + 66 + # move into source root after patching 67 + postPatch = '' 68 + cd psycopg_c 69 + ''; 70 + 71 + nativeBuildInputs = [ 72 + setuptools 73 + cython_3 74 + postgresql 75 + ]; 76 + 77 + # tested in psycopg 78 + doCheck = false; 79 + 80 + meta = baseMeta // { 81 + description = "C optimisation distribution for Psycopg"; 82 + }; 83 + }; 84 + 85 + psycopg-pool = buildPythonPackage { 86 + pname = "${pname}-pool"; 87 + inherit version src; 88 + format = "setuptools"; 89 + 90 + # apply patches to base repo 91 + inherit patches; 92 + 93 + # move into source root after patching 94 + postPatch = '' 95 + cd psycopg_pool 96 + ''; 97 + 98 + propagatedBuildInputs = lib.optionals (pythonOlder "3.10") [ 99 + typing-extensions 100 + ]; 101 + 102 + # tested in psycopg 103 + doCheck = false; 104 + 105 + meta = baseMeta // { 106 + description = "Connection Pool for Psycopg"; 107 + }; 108 + }; 109 + 110 + in 111 + 112 + buildPythonPackage rec { 113 + inherit pname version src; 114 + format = "pyproject"; 115 + 116 + disabled = pythonOlder "3.7"; 117 + 47 118 outputs = [ 48 119 "out" 49 120 "doc" ··· 57 128 hash = "sha256-yn09fR9+7zQni8SvTG7BUmYRD7MK7u2arVAznWz2oAw="; 58 129 }; 59 130 60 - patches = [ 61 - (substituteAll { 62 - src = ./libpq.patch; 63 - libpq = "${postgresql.lib}/lib/libpq${stdenv.hostPlatform.extensions.sharedLibrary}"; 64 - }) 65 - ]; 131 + inherit patches; 66 132 67 133 # only move to sourceRoot after patching, makes patching easier 68 134 postPatch = '' 69 - cd ${pname} 135 + cd psycopg 70 136 ''; 71 137 72 138 nativeBuildInputs = [ 73 139 furo 140 + setuptools 74 141 shapely 75 - sphinxHook 76 142 sphinx-autodoc-typehints 143 + sphinxHook 77 144 ]; 78 145 79 - propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [ 146 + propagatedBuildInputs = [ 147 + psycopg-c 148 + ] ++ lib.optionals (pythonOlder "3.11") [ 80 149 typing-extensions 81 150 ] ++ lib.optionals (pythonOlder "3.9") [ 82 151 backports-zoneinfo ··· 84 153 85 154 pythonImportsCheck = [ 86 155 "psycopg" 156 + "psycopg_c" 157 + "psycopg_pool" 87 158 ]; 88 159 89 160 passthru.optional-dependencies = { 90 - # TODO: package remaining variants 91 - #c = [ psycopg-c ]; 92 - #pool = [ psycopg-pool ]; 161 + c = [ psycopg-c ]; 162 + pool = [ psycopg-pool ]; 93 163 }; 94 164 95 165 preCheck = '' ··· 102 172 pytest-randomly 103 173 pytestCheckHook 104 174 postgresql 105 - ]; 175 + ] 176 + ++ passthru.optional-dependencies.c 177 + ++ passthru.optional-dependencies.pool; 106 178 107 179 disabledTests = [ 108 - # linters shouldn't be run in checks 180 + # don't depend on mypy for tests 109 181 "test_version" 182 + "test_package_version" 183 + ] ++ lib.optionals (stdenv.isDarwin) [ 184 + # racy test 185 + "test_sched" 186 + "test_sched_error" 110 187 ]; 111 188 112 189 disabledTestPaths = [ 113 - # TODO: requires the pooled variant 114 - "tests/pool/" 115 190 # Network access 116 191 "tests/test_dns.py" 117 192 "tests/test_dns_srv.py" ··· 127 202 cd ${pname} 128 203 ''; 129 204 130 - meta = with lib; { 131 - changelog = "https://github.com/psycopg/psycopg/blob/master/docs/news.rst"; 205 + passthru = { 206 + c = psycopg-c; 207 + pool = psycopg-pool; 208 + }; 209 + 210 + meta = baseMeta // { 132 211 description = "PostgreSQL database adapter for Python"; 133 - homepage = "https://github.com/psycopg/psycopg"; 134 - license = licenses.lgpl3Plus; 135 - maintainers = with maintainers; [ hexa ]; 136 212 }; 137 213 }