From b8ea3d2bd61eaf309e6fa7902476fe89c99fceac Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Sun, 11 Aug 2024 12:22:33 +0200 Subject: [PATCH] python3Packages.ziamath: 0.10 -> 0.11 --- .../python-modules/ziamath/checkfonts.nix | 19 +++++++++++ .../python-modules/ziamath/default.nix | 32 ++++++++++--------- 2 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 pkgs/development/python-modules/ziamath/checkfonts.nix diff --git a/pkgs/development/python-modules/ziamath/checkfonts.nix b/pkgs/development/python-modules/ziamath/checkfonts.nix new file mode 100644 index 000000000000..ce29060d3f18 --- /dev/null +++ b/pkgs/development/python-modules/ziamath/checkfonts.nix @@ -0,0 +1,19 @@ +# Based on the calls to testfont(url) in test/styles.ipynb +[ + { + url = "https://mirrors.ctan.org/fonts/libertinus-fonts/otf/LibertinusMath-Regular.otf"; + hash = "sha256-PY4QUzxz9/vO4k2rl5GBfno0r3/Zh1FAhif1OPDic7w="; + } + { + url = "https://mirrors.ctan.org/fonts/firamath/FiraMath-Regular.otf"; + hash = "sha256-ICjL091NjAzxYIUg60dZlWqDpnkx17bY58MTUgGG41s="; + } + { + url = "https://mirrors.ctan.org/fonts/erewhon-math/Erewhon-Math.otf"; + hash = "sha256-7SjKC+XP9KpFAWtZxc+FZZ4VETnDxokUGz+nZ/CWIbI="; + } + { + url = "https://mirrors.ctan.org/fonts/concmath-otf/Concrete-Math.otf"; + hash = "sha256-YCukkUgNQoBlotuD0vF1ts9JL8x6xaEW9JxK++GVGZ4="; + } +] diff --git a/pkgs/development/python-modules/ziamath/default.nix b/pkgs/development/python-modules/ziamath/default.nix index ac2cd8610929..7505d578ba52 100644 --- a/pkgs/development/python-modules/ziamath/default.nix +++ b/pkgs/development/python-modules/ziamath/default.nix @@ -8,20 +8,20 @@ pytestCheckHook, nbval, latex2mathml, + fetchurl, }: - buildPythonPackage rec { pname = "ziamath"; - version = "0.10"; + version = "0.11"; pyproject = true; disabled = pythonOlder "3.8"; src = fetchFromGitHub { owner = "cdelker"; - repo = pname; - rev = version; - hash = "sha256-Drssi+YySh4OhVYAOvgIwzeeu5dQbUUXuhwTedhUUt8="; + repo = "ziamath"; + rev = "refs/tags/${version}"; + hash = "sha256-DLpbidQEeQVKxGCbS2jeeCvmVK9ElDIDQMj5bh/x7/Q="; }; build-system = [ setuptools ]; @@ -34,22 +34,24 @@ buildPythonPackage rec { latex2mathml ]; - pytestFlagsArray = [ "--nbval-lax" ]; + preCheck = + let + # The test notebooks try to download font files, unless they already exist in the test directory, + # so we prepare them in advance. + checkFonts = lib.map fetchurl (import ./checkfonts.nix); + copyFontCmd = font: "cp ${font} test/${lib.last (lib.splitString "/" font.url)}\n"; + in + lib.concatMapStrings copyFontCmd checkFonts; - # Prevent the test suite from attempting to download fonts - postPatch = '' - substituteInPlace test/styles.ipynb \ - --replace '"def testfont(exprs, fonturl):\n",' '"def testfont(exprs, fonturl):\n", " return\n",' \ - --replace "mathfont='FiraMath-Regular.otf', " "" - ''; + pytestFlagsArray = [ "--nbval-lax" ]; pythonImportsCheck = [ "ziamath" ]; - meta = with lib; { + meta = { description = "Render MathML and LaTeX Math to SVG without Latex installation"; homepage = "https://ziamath.readthedocs.io/en/latest/"; changelog = "https://ziamath.readthedocs.io/en/latest/changes.html"; - license = licenses.mit; - maintainers = with maintainers; [ sfrijters ]; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.sfrijters ]; }; }