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