summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/backports-zstd/default.nix
blob: ec965af56c47fce61d0f56512b4cfce0791dd73f (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
54
55
56
57
58
59
60
61
{
  buildPythonPackage,
  fetchFromGitHub,
  lib,
  pytestCheckHook,
  setuptools,
  zstd,
}:

buildPythonPackage rec {
  pname = "backports-zstd";
  version = "1.1.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rogdham";
    repo = "backports.zstd";
    tag = "v${version}";
    fetchSubmodules = true;
    postFetch = ''
      rm -r "$out/src/c/zstd"
    '';
    hash = "sha256-qgPtLl8oPvM9XDlW72NNX1JqCxzcnLlHyUNNxU9e2PY=";
  };

  postPatch = ''
    substituteInPlace setup.py \
      --replace-fail 'ROOT_PATH / "src" / "c" / "zstd"' 'Path("${zstd.src}")'

    # need to preserve $PYTHONPATH when calling sys.executable
    substituteInPlace tests/test/support/script_helper.py \
      --replace-fail "return __cached_interp_requires_environment" "return True"
  '';

  build-system = [ setuptools ];

  pypaBuildFlags = [ "--config-setting=--build-option=--system-zstd" ];

  buildInputs = [ zstd ];

  pythonImportsCheck = [ "backports.zstd" ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  enabledTestPaths = [ "tests" ];

  disabledTestPaths = [
    # sandbox doesn't allow setting SUID bit
    "tests/test/test_tarfile.py::TestExtractionFilters::test_modes"
  ];

  meta = {
    changelog = "https://github.com/rogdham/backports.zstd/blob/${src.tag}/CHANGELOG.md";
    description = "Backport of compression.zstd";
    homepage = "https://github.com/rogdham/backports.zstd";
    license = lib.licenses.psfl;
    maintainers = [ lib.maintainers.dotlambda ];
  };
}