diff --git a/pkgs/development/python-modules/ziafont/checkfonts.nix b/pkgs/development/python-modules/ziafont/checkfonts.nix new file mode 100644 index 000000000000..773d8a1ea066 --- /dev/null +++ b/pkgs/development/python-modules/ziafont/checkfonts.nix @@ -0,0 +1,88 @@ +# Based on the calls to testfont(url) in test/manyfonts.ipynb +# Note that Tinos-Regular is also needed for test/test.ipynb +[ + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTAbbie.otf"; + hash = "sha256-/Lu7EGtF7kZgP0dYyaIFPIO7jWCbtc3iT0ux3bFhe9w="; + } + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTJupiter.otf"; + hash = "sha256-BocJZnrGGt1fpq5Jmnl1fiuo7YllN5xCF6lgWZyVcXE="; + } + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTVagaRound.otf"; + hash = "sha256-JffWcGdBN2OIZXdZxf7G3G+kZRZi2cKFUIOAOCuR8gM="; + } + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTBlackForest.otf"; + hash = "sha256-P4TQSCBHPfty3l+IhY1CuVkr0KNk2t6bbeieT21fz9A="; + } + { + url = "https://mirrors.ctan.org/fonts/punknova/punknova-regular.otf"; + hash = "sha256-UC4Zdh647wTBYXRyOzFDliVA0ukK88K8CcIS8nzxeoo="; + } + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTSnowCaps.otf"; + hash = "sha256-XtZbEhCcHlc1eHEkR+52tuVoA6GTf//5mU/ehHq/H8g="; + } + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTStoryTimeCaps.otf"; + hash = "sha256-bwW8KZD40i8rpGqZuoVBeosfjk/tWHex4KPm8mlQ4po="; + } + { + url = "https://mirrors.ctan.org/fonts/alegreya/opentype/Alegreya-Regular.otf"; + hash = "sha256-oZo6XeaTcnaSymYWrkl71t3JsWvLuKgKsNAirONNax4="; + } + { + url = "https://mirrors.ctan.org/fonts/nimbus15/opentype/zco-Oblique.otf"; + hash = "sha256-j7WbsSnLGh+OdpdBwIlp3cPL8rpYS3OcW3jtxltgArE="; + } + { + url = "https://mirrors.ctan.org/fonts/merriweather/opentype/Merriweather-Black.otf"; + hash = "sha256-3pQdqHw1eRUVCRwnVbZBbftrZ7fJ7USD+CyNfA41u3g="; + } + { + url = "https://mirrors.ctan.org/fonts/qualitype/opentype/QTArtiston.otf"; + hash = "sha256-6bfL3Po4erta9q49EgzYZXZs9NtdoWFjnpR3WT1y+vU="; + } + { + url = "https://mirrors.ctan.org/fonts/nunito/opentype/Nunito-Black.otf"; + hash = "sha256-/QJud/q2MVwrXEibDDe/gty3a3x2weodNBqCOkVV7fA="; + } + { + url = "https://mirrors.ctan.org/fonts/kurier/fonts/opentype/nowacki/kurier/KurierHeavy-Regular.otf"; + hash = "sha256-ynFz+IIntQeEK2+Cu64wJRTffZvmuYdx1IrKKDe1VA0="; + } + { + url = "https://mirrors.ctan.org/fonts/clearsans/truetype/ClearSans-MediumItalic.ttf"; + hash = "sha256-Bv+6I2ClJo71iZbj3XmUpJ3NHBZ/+8h07azt7ucbmyE="; + } + { + url = "https://mirrors.ctan.org/fonts/tinos/truetype/Tinos-Regular.ttf"; + hash = "sha256-/03rOV/yQmu9CNt0ywBbIjJhdd8A8KFWuH5tKu8e9Qg="; + } + { + url = "https://mirrors.ctan.org/fonts/gofonts/truetype/Go-Medium.ttf"; + hash = "sha256-GvMsI34wBeBQUC9RQjVNS6TukXf5faoVrPoI9L9qPEY="; + } + { + url = "https://mirrors.ctan.org/fonts/comfortaa/truetype/Comfortaa-Regular.ttf"; + hash = "sha256-eu7K9MeZ8k8i6HGm9UbKiRFs8RKIx6j/QvEUAd1URcY="; + } + { + url = "https://mirrors.ctan.org/fonts/quattrocento/truetype/Quattrocento-Regular.ttf"; + hash = "sha256-kv5NsgyBybySJha4xJ4VIEaCdMfJwyz19VRCJOwVeHs="; + } + { + url = "https://mirrors.ctan.org/fonts/kurier/fonts/opentype/nowacki/kurier/KurierCond-Regular.otf"; + hash = "sha256-y9gD/ovTuZeh5/OaQelhGLuTPFjLcPSMLfIUyHe1QXI="; + } + { + url = "https://mirrors.ctan.org/fonts/garamond-math/Garamond-Math.otf"; + hash = "sha256-xhYTd+lwhBUrlI9iq+h0y+J0BZOJVjRrVKTGSIpQCfE="; + } + { + url = "https://github.com/google/fonts/raw/main/ofl/arizonia/Arizonia-Regular.ttf"; + hash = "sha256-jfHBC8FdCroUXUWZwlyvrYPbaG0s76QmGfBptvG7zmI="; + } +] diff --git a/pkgs/development/python-modules/ziafont/default.nix b/pkgs/development/python-modules/ziafont/default.nix index 8f4f9f876991..c25177dc23c1 100644 --- a/pkgs/development/python-modules/ziafont/default.nix +++ b/pkgs/development/python-modules/ziafont/default.nix @@ -6,20 +6,20 @@ setuptools, pytestCheckHook, nbval, + fetchurl, }: - buildPythonPackage rec { pname = "ziafont"; - version = "0.8"; + version = "0.9"; pyproject = true; disabled = pythonOlder "3.8"; src = fetchFromGitHub { owner = "cdelker"; - repo = pname; - rev = version; - hash = "sha256-C+dC+mNquDuj6RfJpiEbeuGZOIXcgSrTB4XM21reBPs="; + repo = "ziafont"; + rev = "refs/tags/${version}"; + hash = "sha256-S7IDL3ItP14/GrCUtSTT+JWuqRAY/Po0Kerq8mggDdg="; }; build-system = [ setuptools ]; @@ -29,16 +29,24 @@ buildPythonPackage rec { nbval ]; - preCheck = "rm test/manyfonts.ipynb"; # Tries to download fonts + 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; pytestFlagsArray = [ "--nbval-lax" ]; pythonImportsCheck = [ "ziafont" ]; - meta = with lib; { + meta = { description = "Convert TTF/OTF font glyphs to SVG paths"; homepage = "https://ziafont.readthedocs.io/en/latest/"; - license = licenses.mit; - maintainers = with maintainers; [ sfrijters ]; + changelog = "https://github.com/cdelker/ziafont/blob/main/CHANGES.md"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.sfrijters ]; }; } 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 ]; }; }