Unverified Commit b0e28881 authored by Martin Weinelt's avatar Martin Weinelt
Browse files

python313Packages.asyncpg: fix build

Probably after changes to the postgresql/libpq packaging the package did
not find pg_config nor pg_ctl.

Took the chance to modernize it at the same time.
parent 9b261742
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -3,18 +3,21 @@
  fetchPypi,
  buildPythonPackage,
  async-timeout,
  cython,
  libpq,
  uvloop,
  postgresql,
  pythonOlder,
  pytest-xdist,
  pytestCheckHook,
  setuptools,
  distro,
}:

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

  disabled = pythonOlder "3.8";

@@ -23,14 +26,17 @@ buildPythonPackage rec {
    hash = "sha256-xVHpkoq2cHYC9EgRgX+CujxEbgGL/h06vsyLpfPqyFE=";
  };

  # sandboxing issues on aarch64-darwin, see https://github.com/NixOS/nixpkgs/issues/198495
  doCheck = postgresql.doInstallCheck;
  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
  propagatedBuildInputs = lib.optionals (pythonOlder "3.11") [ async-timeout ];
  dependencies = lib.optionals (pythonOlder "3.11") [ async-timeout ];

  nativeCheckInputs = [
    libpq.pg_config
    uvloop
    postgresql
    pytest-xdist
@@ -38,8 +44,13 @@ buildPythonPackage rec {
    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