From 9ef74b5fc46758c1daa8e2a5c5d05ecf9625e07a Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Sun, 26 Nov 2023 09:24:44 +1100 Subject: [PATCH] fontbakery: init at 0.10.40 --- .../python-modules/fontbakery/default.nix | 146 ++++++++++++++++++ .../python-modules/fontbakery/tests.nix | 22 +++ pkgs/top-level/all-packages.nix | 2 + pkgs/top-level/python-packages.nix | 2 + 4 files changed, 172 insertions(+) create mode 100644 pkgs/development/python-modules/fontbakery/default.nix create mode 100644 pkgs/development/python-modules/fontbakery/tests.nix diff --git a/pkgs/development/python-modules/fontbakery/default.nix b/pkgs/development/python-modules/fontbakery/default.nix new file mode 100644 index 000000000000..b824ca990b8a --- /dev/null +++ b/pkgs/development/python-modules/fontbakery/default.nix @@ -0,0 +1,146 @@ +{ lib +, buildPythonPackage +, callPackage +, fetchpatch +, fetchPypi +, axisregistry +, babelfont +, beautifulsoup4 +, beziers +, cmarkgfm +, collidoscope +, defcon +, dehinter +, fonttools +, font-v +, freetype-py +, gflanguages +, git +, glyphsets +, lxml +, installShellFiles +, munkres +, opentypespec +, ots-python +, packaging +, pip-api +, protobuf +, pytestCheckHook +, pytest-xdist +, pythonRelaxDepsHook +, pyyaml +, requests +, requests-mock +, rich +, setuptools-scm +, shaperglot +, stringbrewer +, toml +, unicodedata2 +, ufo2ft +, ufolint +, vharfbuzz +}: + +buildPythonPackage rec { + pname = "fontbakery"; + version = "0.10.4"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-Ye/TMGvURxSU2yoohwYbSo5RvrmbHKdMnFNj2lUvtMk="; + }; + + patches = [ + # Mock HTTP requests in tests (note we still have to skip some below) + # https://github.com/googlefonts/fontbakery/pull/4124 + (fetchpatch { + url = "https://github.com/fonttools/fontbakery/pull/4124.patch"; + hash = "sha256-NXuC2+TtxpHYMdd0t+cF0FJ3lrh4exP5yxspEasKKd0="; + }) + ]; + + propagatedBuildInputs = [ + axisregistry + babelfont + beautifulsoup4 + beziers + cmarkgfm + collidoscope + defcon + dehinter + fonttools + font-v + freetype-py + gflanguages + glyphsets + lxml + munkres + ots-python + opentypespec + packaging + pip-api + protobuf + pyyaml + requests + rich + shaperglot + stringbrewer + toml + ufolint + unicodedata2 + vharfbuzz + ufo2ft + ]; + nativeBuildInputs = [ + installShellFiles + pythonRelaxDepsHook + setuptools-scm + ]; + + pythonRelaxDeps = [ + "collidoscope" + "protobuf" + "vharfbuzz" + ]; + + doCheck = true; + nativeCheckInputs = [ + git + pytestCheckHook + pytest-xdist + requests-mock + ufolint + ]; + preCheck = '' + # Let the tests invoke 'fontbakery' command. + export PATH="$out/bin:$PATH" + # font-v tests assume they are running from a git checkout, although they + # don't care which one. Create a dummy git repo to satisfy the tests: + git init -b main + git config user.email test@example.invalid + git config user.name Test + git commit --allow-empty --message 'Dummy commit for tests' + ''; + disabledTests = [ + # These require network access: + "test_check_vertical_metrics_regressions" + "test_check_cjk_vertical_metrics_regressions" + "test_check_fontbakery_version_live_apis" + ]; + + postInstall = '' + installShellCompletion --bash --name fontbakery \ + snippets/fontbakery.bash-completion + ''; + + passthru.tests.simple = callPackage ./tests.nix { }; + + meta = with lib; { + description = "Tool for checking the quality of font projects"; + homepage = "https://github.com/googlefonts/fontbakery"; + license = licenses.asl20; + maintainers = with maintainers; [ danc86 ]; + }; +} + diff --git a/pkgs/development/python-modules/fontbakery/tests.nix b/pkgs/development/python-modules/fontbakery/tests.nix new file mode 100644 index 000000000000..4725b1fee3e3 --- /dev/null +++ b/pkgs/development/python-modules/fontbakery/tests.nix @@ -0,0 +1,22 @@ +{ runCommand +, fontbakery +}: + +let + inherit (fontbakery) pname version src; +in + +runCommand "${pname}-tests" { meta.timeout = 5; } '' + # Check the version matches what we packaged. + ${fontbakery}/bin/fontbakery --version | grep -q "${version}" + + # Can it list its own subcommands? + ${fontbakery}/bin/fontbakery --list-subcommands >>$out + + # Unpack src to get some test fonts. + tar -xzf ${src} --strip-components=1 ${pname}-${version}/data/test + + # Run some font checks. + ${fontbakery}/bin/fontbakery check-ufo-sources --no-progress --no-colors data/test/test.ufo >>$out + # TODO add more +'' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ce9f1ee73d44..e2d097457b0d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1810,6 +1810,8 @@ with pkgs; font-v = with python3Packages; toPythonApplication font-v; + fontbakery = with python3Packages; toPythonApplication fontbakery; + weidu = callPackage ../tools/games/weidu { }; weylus = callPackage ../applications/graphics/weylus { diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 20e676d49542..03a2f6ea818e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4177,6 +4177,8 @@ self: super: with self; { fontawesomefree = callPackage ../development/python-modules/fontawesomefree { }; + fontbakery = callPackage ../development/python-modules/fontbakery { }; + fontfeatures = callPackage ../development/python-modules/fontfeatures { }; fontforge = toPythonModule (pkgs.fontforge.override {