1{
2 lib,
3 fetchPypi,
4 buildPythonPackage,
5 async-timeout,
6 uvloop,
7 postgresql,
8 pythonOlder,
9 pytest-xdist,
10 pytestCheckHook,
11}:
12
13buildPythonPackage rec {
14 pname = "asyncpg";
15 version = "0.29.0";
16 format = "setuptools";
17
18 disabled = pythonOlder "3.8";
19
20 src = fetchPypi {
21 inherit pname version;
22 hash = "sha256-0cSeH0T/+v2aVeGpsQFZCFnYgdY56ikiUW9dnFEtNU4=";
23 };
24
25 # sandboxing issues on aarch64-darwin, see https://github.com/NixOS/nixpkgs/issues/198495
26 doCheck = postgresql.doCheck;
27
28 # required for compatibility with Python versions older than 3.11
29 # see https://github.com/MagicStack/asyncpg/blob/v0.29.0/asyncpg/_asyncio_compat.py#L13
30 propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [ async-timeout ];
31
32 nativeCheckInputs = [
33 uvloop
34 postgresql
35 pytest-xdist
36 pytestCheckHook
37 ];
38
39 preCheck = ''
40 rm -rf asyncpg/
41 '';
42
43 pythonImportsCheck = [ "asyncpg" ];
44
45 meta = with lib; {
46 description = "Asyncio PosgtreSQL driver";
47 homepage = "https://github.com/MagicStack/asyncpg";
48 changelog = "https://github.com/MagicStack/asyncpg/releases/tag/v${version}";
49 longDescription = ''
50 Asyncpg is a database interface library designed specifically for
51 PostgreSQL and Python/asyncio. asyncpg is an efficient, clean
52 implementation of PostgreSQL server binary protocol for use with Python's
53 asyncio framework.
54 '';
55 license = licenses.asl20;
56 maintainers = with maintainers; [ eadwu ];
57 };
58}