summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/asyncpg/default.nix
blob: afd0c609cb3fe7d8b3d68fabdc57b50a7655f3a8 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
  lib,
  fetchPypi,
  buildPythonPackage,
  async-timeout,
  cython,
  libpq,
  uvloop,
  postgresql,
  pythonOlder,
  pytest-xdist,
  pytestCheckHook,
  setuptools,
  distro,
}:

buildPythonPackage rec {
  pname = "asyncpg";
  version = "0.30.0";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-xVHpkoq2cHYC9EgRgX+CujxEbgGL/h06vsyLpfPqyFE=";
  };

  build-system = [
    cython
    setuptools
  ];

  # required for compatibility with Python versions older than 3.11
  # see https://github.com/MagicStack/asyncpg/blob/v0.29.0/asyncpg/_asyncio_compat.py#L13
  dependencies = lib.optionals (pythonOlder "3.11") [ async-timeout ];

  nativeCheckInputs = [
    libpq.pg_config
    uvloop
    postgresql
    pytest-xdist
    pytestCheckHook
    distro
  ];

  # sandboxing issues on aarch64-darwin, see https://github.com/NixOS/nixpkgs/issues/198495
  doCheck = postgresql.doInstallCheck;

  preCheck = ''
    rm -rf asyncpg/

    export PGBIN=${lib.getBin postgresql}/bin
  '';

  # https://github.com/MagicStack/asyncpg/issues/1236
  disabledTests = [ "test_connect_params" ];

  pythonImportsCheck = [ "asyncpg" ];

  meta = with lib; {
    description = "Asyncio PosgtreSQL driver";
    homepage = "https://github.com/MagicStack/asyncpg";
    changelog = "https://github.com/MagicStack/asyncpg/releases/tag/v${version}";
    longDescription = ''
      Asyncpg is a database interface library designed specifically for
      PostgreSQL and Python/asyncio. asyncpg is an efficient, clean
      implementation of PostgreSQL server binary protocol for use with Python's
      asyncio framework.
    '';
    license = licenses.asl20;
    maintainers = with maintainers; [ eadwu ];
  };
}