summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/zstandard/default.nix
blob: 4b38b8406c2e925856f3679513ba7e630c83796c (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
{
  lib,
  buildPythonPackage,
  fetchPypi,
  isPyPy,
  cffi,
  setuptools,
  hypothesis,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "zstandard";
  version = "0.23.0";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-stjGLQjnJV9o96dAuuhbPJuOVGa6qcv39X8c3grGvAk=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "setuptools<69.0.0" "setuptools" \
      --replace-fail "cffi==" "cffi>="
  '';

  build-system = [
    cffi
    setuptools
  ];

  dependencies = lib.optionals isPyPy [ cffi ];

  # python-zstandard depends on unstable zstd C APIs and may break with version mismatches,
  # so we don't provide system zstd for this package
  # https://github.com/indygreg/python-zstandard/blob/9eb56949b1764a166845e065542690942a3203d3/c-ext/backend_c.c#L137-L150

  nativeCheckInputs = [
    hypothesis
    pytestCheckHook
  ];

  preCheck = ''
    rm -r zstandard
  '';

  pythonImportsCheck = [ "zstandard" ];

  meta = {
    description = "Zstandard bindings for Python";
    homepage = "https://github.com/indygreg/python-zstandard";
    license = lib.licenses.bsdOriginal;
    maintainers = with lib.maintainers; [ arnoldfarkas ];
  };
}