1{
2 lib,
3 fetchPypi,
4 buildPythonPackage,
5 async-timeout,
6 cython,
7 libpq,
8 uvloop,
9 postgresql,
10 pythonOlder,
11 pytest-xdist,
12 pytestCheckHook,
13 setuptools,
14 distro,
15}:
16
17buildPythonPackage rec {
18 pname = "asyncpg";
19 version = "0.30.0";
20 pyproject = true;
21
22 disabled = pythonOlder "3.8";
23
24 src = fetchPypi {
25 inherit pname version;
26 hash = "sha256-xVHpkoq2cHYC9EgRgX+CujxEbgGL/h06vsyLpfPqyFE=";
27 };
28
29 build-system = [
30 cython
31 setuptools
32 ];
33
34 # required for compatibility with Python versions older than 3.11
35 # see https://github.com/MagicStack/asyncpg/blob/v0.29.0/asyncpg/_asyncio_compat.py#L13
36 dependencies = lib.optionals (pythonOlder "3.11") [ async-timeout ];
37
38 nativeCheckInputs = [
39 libpq.pg_config
40 uvloop
41 postgresql
42 postgresql.pg_config
43 pytest-xdist
44 pytestCheckHook
45 distro
46 ];
47
48 # sandboxing issues on aarch64-darwin, see https://github.com/NixOS/nixpkgs/issues/198495
49 doCheck = postgresql.doInstallCheck;
50
51 preCheck = ''
52 rm -rf asyncpg/
53
54 export PGBIN=${lib.getBin postgresql}/bin
55 '';
56
57 # https://github.com/MagicStack/asyncpg/issues/1236
58 disabledTests = [ "test_connect_params" ];
59
60 pythonImportsCheck = [ "asyncpg" ];
61
62 meta = with lib; {
63 description = "Asyncio PosgtreSQL driver";
64 homepage = "https://github.com/MagicStack/asyncpg";
65 changelog = "https://github.com/MagicStack/asyncpg/releases/tag/v${version}";
66 longDescription = ''
67 Asyncpg is a database interface library designed specifically for
68 PostgreSQL and Python/asyncio. asyncpg is an efficient, clean
69 implementation of PostgreSQL server binary protocol for use with Python's
70 asyncio framework.
71 '';
72 license = licenses.asl20;
73 maintainers = with maintainers; [ eadwu ];
74 };
75}