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