summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/libarchive-c/default.nix
blob: 9501f9bc7cbc6306484c6aab742ec405836b31e1 (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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  libarchive,
  glibcLocales,
  mock,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "libarchive-c";
  version = "5.3";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "Changaco";
    repo = "python-${pname}";
    tag = version;
    sha256 = "sha256-JqXTV1aD3k88OlW+8rT3xsDuW34+1xErG7hkupvL7Uo=";
  };

  patches = [
    # https://github.com/Changaco/python-libarchive-c/pull/141
    (fetchpatch {
      url = "https://github.com/Changaco/python-libarchive-c/commit/e0e2a47b2403632642ee932dd56acd11e4a79efe.diff";
      hash = "sha256-C9eD4cGQOIdBYy4ytom49lA/Jaarj7LbSIgjxCk/H84=";
    })
  ];

  LC_ALL = "en_US.UTF-8";

  postPatch = ''
    substituteInPlace libarchive/ffi.py --replace-fail \
      "find_library('archive')" "'${libarchive.lib}/lib/libarchive${stdenv.hostPlatform.extensions.sharedLibrary}'"
  '';

  pythonImportsCheck = [ "libarchive" ];

  nativeCheckInputs = [
    glibcLocales
    mock
    pytestCheckHook
  ];

  meta = {
    homepage = "https://github.com/Changaco/python-libarchive-c";
    description = "Python interface to libarchive";
    license = lib.licenses.cc0;
  };
}