1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 indexed-gzip,
6 indexed-zstd,
7 libarchive-c,
8 pytestCheckHook,
9 python-xz,
10 pythonOlder,
11 rapidgzip,
12 rarfile,
13 setuptools,
14 zstandard, # Python bindings
15 zstd, # System tool
16}:
17
18buildPythonPackage rec {
19 pname = "ratarmountcore";
20 version = "0.15.2";
21 pyproject = true;
22
23 disabled = pythonOlder "3.10";
24
25 src = fetchFromGitHub {
26 owner = "mxmlnkn";
27 repo = "ratarmount";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-2LPGKdofx2ID8BU0dZhGiZ3tUkd+niEVGvTSBFX4InU=";
30 fetchSubmodules = true;
31 };
32
33 sourceRoot = "${src.name}/core";
34
35 build-system = [ setuptools ];
36
37 optional-dependencies = {
38 full = [
39 indexed-gzip
40 indexed-zstd
41 python-xz
42 rapidgzip
43 rarfile
44 ];
45 _7z = [ libarchive-c ];
46 bzip2 = [ rapidgzip ];
47 gzip = [ indexed-gzip ];
48 rar = [ rarfile ];
49 xz = [ python-xz ];
50 zstd = [ indexed-zstd ];
51 };
52
53 nativeCheckInputs = [
54 pytestCheckHook
55 zstandard
56 zstd
57 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
58
59 pythonImportsCheck = [ "ratarmountcore" ];
60
61 disabledTestPaths = [
62 # Disable this test because for arcane reasons running pytest with nix-build uses 10-100x
63 # more virtual memory than running the test directly or inside a local development nix-shell.
64 # This virtual memory usage caused os.fork called by Python multiprocessing to fail with
65 # "OSError: [Errno 12] Cannot allocate memory" on a test system with 16 GB RAM. It worked fine
66 # on a system with 96 GB RAM. In order to avoid build errors on "low"-memory systems, this
67 # test is disabled for now.
68 "tests/test_BlockParallelReaders.py"
69 ];
70
71 disabledTests = [
72 # Tests with issues
73 "test_file_versions"
74 "test_stream_compressed"
75 "test_chimera_file"
76 ];
77
78 meta = with lib; {
79 description = "Library for accessing archives by way of indexing";
80 homepage = "https://github.com/mxmlnkn/ratarmount/tree/master/core";
81 changelog = "https://github.com/mxmlnkn/ratarmount/blob/core-v${version}/core/CHANGELOG.md";
82 license = licenses.mit;
83 maintainers = with lib.maintainers; [ mxmlnkn ];
84 };
85}