1{
2 lib,
3 pkg-config,
4 fetchPypi,
5 buildPythonPackage,
6 buildPackages,
7 zstd,
8 pytest,
9}:
10
11buildPythonPackage rec {
12 pname = "zstd";
13 version = "1.5.7.2";
14 format = "setuptools";
15
16 src = fetchPypi {
17 inherit pname version;
18 hash = "sha256-bYaExpAJvknhsY7CUaXrDX4k+TYkmQqKEkodpmqS/Io=";
19 };
20
21 postPatch = ''
22 substituteInPlace setup.py \
23 --replace "/usr/bin/pkg-config" "${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config"
24 '';
25
26 nativeBuildInputs = [ pkg-config ];
27 buildInputs = [ zstd ];
28
29 setupPyBuildFlags = [
30 "--external"
31 "--include-dirs=${zstd}/include"
32 "--libraries=zstd"
33 "--library-dirs=${zstd}/lib"
34 ];
35
36 # Running tests via setup.py triggers an attempt to recompile with the vendored zstd
37 ZSTD_EXTERNAL = 1;
38 VERSION = zstd.version;
39 PKG_VERSION = version;
40
41 nativeCheckInputs = [ pytest ];
42 checkPhase = ''
43 pytest
44 '';
45
46 meta = with lib; {
47 description = "Simple python bindings to Yann Collet ZSTD compression library";
48 homepage = "https://github.com/sergey-dryabzhinsky/python-zstd";
49 license = licenses.bsd2;
50 maintainers = with maintainers; [ eadwu ];
51 };
52}