about summary refs log tree commit diff
path: root/pkgs/development/python-modules/manim/default.nix
blob: 09f2953c362e4595897adfa663cae33194503588 (plain) (blame)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{ lib
, buildPythonPackage
, fetchFromGitHub
, poetry-core
, pytest-xdist
, pytestCheckHook
, pythonOlder
, pythonRelaxDepsHook

, cairo
, ffmpeg
, texliveInfraOnly

, click
, click-default-group
, cloup
, colour
, grpcio
, grpcio-tools
, importlib-metadata
, isosurfaces
, jupyterlab
, manimpango
, mapbox-earcut
, moderngl
, moderngl-window
, networkx
, numpy
, pillow
, pycairo
, pydub
, pygments
, rich
, scipy
, screeninfo
, skia-pathops
, srt
, svgelements
, tqdm
, watchdog
}:

let
  # According to ManimCommunity documentation manim uses tex-packages packaged
  # in a custom distribution called "manim-latex",
  #
  #   https://community.chocolatey.org/packages/manim-latex#files
  #
  # which includes another cutom distribution called tinytex, for which the
  # package list can be found at
  #
  #   https://github.com/yihui/tinytex/blob/master/tools/pkgs-custom.txt
  #
  # these two combined add up to:
  manim-tinytex = texliveInfraOnly.withPackages (ps: with ps; [

    # tinytex
    amsfonts amsmath atbegshi atveryend auxhook babel bibtex
    bigintcalc bitset booktabs cm dehyph dvipdfmx dvips ec epstopdf-pkg etex
    etexcmds etoolbox euenc everyshi fancyvrb filehook firstaid float fontspec
    framed geometry gettitlestring glyphlist graphics graphics-cfg graphics-def
    grffile helvetic hycolor hyperref hyph-utf8 iftex inconsolata infwarerr
    intcalc knuth-lib kvdefinekeys kvoptions kvsetkeys l3backend l3kernel
    l3packages latex latex-amsmath-dev latex-bin latex-fonts latex-tools-dev
    latexconfig latexmk letltxmacro lm lm-math ltxcmds lua-alt-getopt luahbtex
    lualatex-math lualibs luaotfload luatex mdwtools metafont mfware natbib
    pdfescape pdftex pdftexcmds plain psnfss refcount rerunfilecheck stringenc
    tex tex-ini-files times tipa tools unicode-data unicode-math uniquecounter
    url xcolor xetex xetexconfig xkeyval xunicode zapfding

    # manim-latex
    standalone everysel preview doublestroke ms setspace rsfs relsize ragged2e
    fundus-calligra microtype wasysym physics dvisvgm jknapltx wasy cm-super
    babel-english gnu-freefont mathastext cbfonts-fd
  ]);

in buildPythonPackage rec {
  pname = "manim";
  pyproject = true;
  version = "0.18.1";
  disabled = pythonOlder "3.9";

  src = fetchFromGitHub {
    owner  = "ManimCommunity";
    repo = "manim";
    rev = "refs/tags/v${version}";
    hash = "sha256-o+Wl3NMK6yopcsRVFtZuUE9c1GABa5d8rbQNHDJ4OiQ=";
  };

  nativeBuildInputs = [
    poetry-core
    pythonRelaxDepsHook
  ];

  pythonRelaxDeps = [
    "cloup"
    "isosurfaces"
    "pillow"
    "skia-pathops"
    "watchdog"
  ];

  patches = [
    ./pytest-report-header.patch
  ];

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace "--no-cov-on-fail --cov=manim --cov-report xml --cov-report term" ""
  '';

  buildInputs = [ cairo ];

  propagatedBuildInputs = [
    click
    click-default-group
    cloup
    colour
    grpcio
    grpcio-tools
    importlib-metadata
    isosurfaces
    jupyterlab
    manimpango
    mapbox-earcut
    moderngl
    moderngl-window
    networkx
    numpy
    pillow
    pycairo
    pydub
    pygments
    rich
    scipy
    screeninfo
    skia-pathops
    srt
    svgelements
    tqdm
    watchdog
  ];

  makeWrapperArgs = [
    "--prefix" "PATH" ":" (lib.makeBinPath [
      ffmpeg
      manim-tinytex
    ])
  ];

  nativeCheckInputs = [
    ffmpeg
    manim-tinytex
    pytest-xdist
    pytestCheckHook
  ];

  # about 55 of ~600 tests failing mostly due to demand for display
  disabledTests = import ./failing_tests.nix;

  pythonImportsCheck = [ "manim" ];

  meta = with lib; {
    description = "Animation engine for explanatory math videos - Community version";
    longDescription = ''
      Manim is an animation engine for explanatory math videos. It's used to
      create precise animations programmatically, as seen in the videos of
      3Blue1Brown on YouTube. This is the community maintained version of
      manim.
    '';
    homepage = "https://github.com/ManimCommunity/manim";
    license = licenses.mit;
    maintainers = with maintainers; [ friedelino ];
  };
}