1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 isPyPy,
6 cffi,
7 setuptools,
8 hypothesis,
9 pytestCheckHook,
10}:
11
12buildPythonPackage rec {
13 pname = "zstandard";
14 version = "0.23.0";
15 pyproject = true;
16
17 src = fetchPypi {
18 inherit pname version;
19 hash = "sha256-stjGLQjnJV9o96dAuuhbPJuOVGa6qcv39X8c3grGvAk=";
20 };
21
22 postPatch = ''
23 substituteInPlace pyproject.toml \
24 --replace-fail "setuptools<69.0.0" "setuptools" \
25 --replace-fail "cffi==" "cffi>="
26 '';
27
28 build-system = [
29 cffi
30 setuptools
31 ];
32
33 dependencies = lib.optionals isPyPy [ cffi ];
34
35 # python-zstandard depends on unstable zstd C APIs and may break with version mismatches,
36 # so we don't provide system zstd for this package
37 # https://github.com/indygreg/python-zstandard/blob/9eb56949b1764a166845e065542690942a3203d3/c-ext/backend_c.c#L137-L150
38
39 nativeCheckInputs = [
40 hypothesis
41 pytestCheckHook
42 ];
43
44 preCheck = ''
45 rm -r zstandard
46 '';
47
48 pythonImportsCheck = [ "zstandard" ];
49
50 meta = {
51 description = "Zstandard bindings for Python";
52 homepage = "https://github.com/indygreg/python-zstandard";
53 license = lib.licenses.bsdOriginal;
54 maintainers = with lib.maintainers; [ arnoldfarkas ];
55 };
56}