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