1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 setuptools,
7 ziafont,
8 pytestCheckHook,
9 nbval,
10 latex2mathml,
11 fetchurl,
12}:
13buildPythonPackage rec {
14 pname = "ziamath";
15 version = "0.11";
16 pyproject = true;
17
18 disabled = pythonOlder "3.8";
19
20 src = fetchFromGitHub {
21 owner = "cdelker";
22 repo = "ziamath";
23 rev = "refs/tags/${version}";
24 hash = "sha256-DLpbidQEeQVKxGCbS2jeeCvmVK9ElDIDQMj5bh/x7/Q=";
25 };
26
27 build-system = [ setuptools ];
28
29 dependencies = [ ziafont ];
30
31 nativeCheckInputs = [
32 pytestCheckHook
33 nbval
34 latex2mathml
35 ];
36
37 preCheck =
38 let
39 # The test notebooks try to download font files, unless they already exist in the test directory,
40 # so we prepare them in advance.
41 checkFonts = lib.map fetchurl (import ./checkfonts.nix);
42 copyFontCmd = font: "cp ${font} test/${lib.last (lib.splitString "/" font.url)}\n";
43 in
44 lib.concatMapStrings copyFontCmd checkFonts;
45
46 pytestFlagsArray = [ "--nbval-lax" ];
47
48 pythonImportsCheck = [ "ziamath" ];
49
50 meta = {
51 description = "Render MathML and LaTeX Math to SVG without Latex installation";
52 homepage = "https://ziamath.readthedocs.io/en/latest/";
53 changelog = "https://ziamath.readthedocs.io/en/latest/changes.html";
54 license = lib.licenses.mit;
55 maintainers = [ lib.maintainers.sfrijters ];
56 };
57}