1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 hatchling,
6 jupyter,
7 nbconvert,
8 numpy,
9 parameterized,
10 pillow,
11 pytestCheckHook,
12 pythonOlder,
13 torch,
14}:
15
16buildPythonPackage rec {
17 pname = "einops";
18 version = "0.8.1";
19 pyproject = true;
20
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "arogozhnikov";
25 repo = "einops";
26 tag = "v${version}";
27 hash = "sha256-J9m5LMOleHf2UziUbOtwf+DFpu/wBDcAyHUor4kqrR8=";
28 };
29
30 nativeBuildInputs = [ hatchling ];
31
32 nativeCheckInputs = [
33 jupyter
34 nbconvert
35 numpy
36 parameterized
37 pillow
38 pytestCheckHook
39 torch
40 ];
41
42 env.EINOPS_TEST_BACKENDS = "numpy";
43
44 preCheck = ''
45 export HOME=$(mktemp -d);
46 '';
47
48 pythonImportsCheck = [ "einops" ];
49
50 disabledTests = [
51 # Tests are failing as mxnet is not pulled-in
52 # https://github.com/NixOS/nixpkgs/issues/174872
53 "test_all_notebooks"
54 "test_dl_notebook_with_all_backends"
55 "test_backends_installed"
56 # depends on tensorflow, which is not available on Python 3.13
57 "test_notebook_2_with_all_backends"
58 ];
59
60 disabledTestPaths = [ "einops/tests/test_layers.py" ];
61
62 __darwinAllowLocalNetworking = true;
63
64 meta = with lib; {
65 changelog = "https://github.com/arogozhnikov/einops/releases/tag/${src.tag}";
66 description = "Flexible and powerful tensor operations for readable and reliable code";
67 homepage = "https://github.com/arogozhnikov/einops";
68 license = licenses.mit;
69 maintainers = with maintainers; [ yl3dy ];
70 };
71}