From e8a723411272ce0a8ec21392f7541b1d39d6702d Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 17 Jul 2023 21:16:50 +0200 Subject: [PATCH 1/4] python3Packages.ninja-python: init at 1.11.1 --- .../python-modules/ninja/default.nix | 72 +++++++++++++++++++ .../python-modules/ninja/no-download.patch | 10 +++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 84 insertions(+) create mode 100644 pkgs/development/python-modules/ninja/default.nix create mode 100644 pkgs/development/python-modules/ninja/no-download.patch diff --git a/pkgs/development/python-modules/ninja/default.nix b/pkgs/development/python-modules/ninja/default.nix new file mode 100644 index 000000000000..d3ab12c29a55 --- /dev/null +++ b/pkgs/development/python-modules/ninja/default.nix @@ -0,0 +1,72 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, fetchurl +, cmake +, setuptools-scm +, scikit-build +, pytestCheckHook +, pytest-virtualenv +}: +let + # these must match NinjaUrls.cmake + ninja_src_url = "https://github.com/Kitware/ninja/archive/v1.11.1.g95dee.kitware.jobserver-1.tar.gz"; + ninja_src_sha256 = "7ba84551f5b315b4270dc7c51adef5dff83a2154a3665a6c9744245c122dd0db"; + ninja_src = fetchurl { + url = ninja_src_url; + sha256 = ninja_src_sha256; + }; +in +buildPythonPackage rec { + pname = "ninja"; + version = "1.11.1"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "scikit-build"; + repo = "ninja-python-distributions"; + rev = version; + hash = "sha256-scCYsSEyN+u3qZhNhWYqHpJCl+JVJJbKz+T34gOXGJM="; + }; + patches = [ + # make sure cmake doesn't try to download the ninja sources + ./no-download.patch + ]; + + inherit ninja_src; + postUnpack = '' + # assume that if the hash matches, the source should be fine + if ! grep "${ninja_src_sha256}" $sourceRoot/NinjaUrls.cmake; then + echo "ninja_src_sha256 doesn't match the hash in NinjaUrls.cmake!" + exit 1 + fi + mkdir -p "$sourceRoot/Ninja-src" + pushd "$sourceRoot/Ninja-src" + tar -xavf ${ninja_src} --strip-components 1 + popd + ''; + + postPatch = '' + sed -i '/cov/d' setup.cfg + ''; + + dontUseCmakeConfigure = true; + + nativeBuildInputs = [ + setuptools-scm + scikit-build + cmake + ]; + + nativeCheckInputs = [ + pytestCheckHook + pytest-virtualenv + ]; + + meta = with lib; { + description = "A small build system with a focus on speed"; + homepage = "https://github.com/scikit-build/ninja-python-distributions"; + license = licenses.asl20; + maintainers = with maintainers; [ _999eagle ]; + }; +} diff --git a/pkgs/development/python-modules/ninja/no-download.patch b/pkgs/development/python-modules/ninja/no-download.patch new file mode 100644 index 000000000000..0937a5fde1ea --- /dev/null +++ b/pkgs/development/python-modules/ninja/no-download.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -64,6 +64,7 @@ + # Download selected source archive + ExternalProject_add(download_ninja_source + SOURCE_DIR ${Ninja_SOURCE_DIR} ++ DOWNLOAD_COMMAND "" + URL ${${src_archive}_url} + URL_HASH SHA256=${${src_archive}_sha256} + DOWNLOAD_DIR ${ARCHIVE_DOWNLOAD_DIR} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5840c7d3bbef..2d346eb268d6 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6916,6 +6916,8 @@ self: super: with self; { nine = callPackage ../development/python-modules/nine { }; + ninja-python = callPackage ../development/python-modules/ninja { }; + nipy = callPackage ../development/python-modules/nipy { }; nipype = callPackage ../development/python-modules/nipype { From aaef56b7baeea7b80941fd2d65895f0e84eb36d3 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 17 Jul 2023 21:17:18 +0200 Subject: [PATCH 2/4] python3Packages.picosvg: init at 0.22.0 --- .../python-modules/picosvg/default.nix | 57 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 59 insertions(+) create mode 100644 pkgs/development/python-modules/picosvg/default.nix diff --git a/pkgs/development/python-modules/picosvg/default.nix b/pkgs/development/python-modules/picosvg/default.nix new file mode 100644 index 000000000000..a04479cfb414 --- /dev/null +++ b/pkgs/development/python-modules/picosvg/default.nix @@ -0,0 +1,57 @@ +{ lib +, stdenv +, buildPythonPackage +, fetchFromGitHub +, fetchpatch +, setuptools-scm +, absl-py +, lxml +, skia-pathops +, pytestCheckHook +}: +buildPythonPackage rec { + pname = "picosvg"; + version = "0.22.0"; + + src = fetchFromGitHub { + owner = "googlefonts"; + repo = pname; + rev = "v${version}"; + hash = "sha256-J06ijF1c3ZKPqKiQha6yqfj8EjFZoZzA6i6UCCrexi8="; + }; + + patches = [ + # see https://github.com/googlefonts/picosvg/issues/299 + # this patch fixed a failing test case after the update to skia-pathops 0.8 + # as soon as skia-pathops in nixpkgs is updated to 0.8, this patch should be removed + (fetchpatch { + url = "https://github.com/googlefonts/picosvg/commit/4e971ed6cd9afb412b2845d29296a0c24f086562.patch"; + hash = "sha256-OZEipNPCSuuqcy4XggBiuGv4HN604dI4N9wlznyAwF0="; + revert = true; + }) + ]; + + nativeBuildInputs = [ + setuptools-scm + ]; + + propagatedBuildInputs = [ + absl-py + lxml + skia-pathops + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + # a few tests are failing on aarch64 + doCheck = !stdenv.isAarch64; + + meta = with lib; { + description = "Tool to simplify SVGs"; + homepage = "https://github.com/googlefonts/picosvg"; + license = licenses.asl20; + maintainers = with maintainers; [ _999eagle ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 2d346eb268d6..7ffe3f42daa5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7764,6 +7764,8 @@ self: super: with self; { picos = callPackage ../development/python-modules/picos { }; + picosvg = callPackage ../development/python-modules/picosvg { }; + piccolo-theme = callPackage ../development/python-modules/piccolo-theme { }; pid = callPackage ../development/python-modules/pid { }; From 1ce92c15f2cc96e02b3b43ee3b2cd8ff86f68432 Mon Sep 17 00:00:00 2001 From: Sophie Tauchert Date: Mon, 17 Jul 2023 21:17:41 +0200 Subject: [PATCH 3/4] nanoemoji: init at 0.15.1 --- pkgs/tools/misc/nanoemoji/default.nix | 72 +++++++++++++++++++ pkgs/tools/misc/nanoemoji/fix-test.patch | 24 +++++++ .../misc/nanoemoji/test-pythonpath.patch | 14 ++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 112 insertions(+) create mode 100644 pkgs/tools/misc/nanoemoji/default.nix create mode 100644 pkgs/tools/misc/nanoemoji/fix-test.patch create mode 100644 pkgs/tools/misc/nanoemoji/test-pythonpath.patch diff --git a/pkgs/tools/misc/nanoemoji/default.nix b/pkgs/tools/misc/nanoemoji/default.nix new file mode 100644 index 000000000000..0e584bc978aa --- /dev/null +++ b/pkgs/tools/misc/nanoemoji/default.nix @@ -0,0 +1,72 @@ +{ lib +, python3 +, fetchFromGitHub +, resvg +, pngquant +}: +python3.pkgs.buildPythonApplication rec { + pname = "nanoemoji"; + version = "0.15.1"; + + src = fetchFromGitHub { + owner = "googlefonts"; + repo = pname; + rev = "v${version}"; + hash = "sha256-P/lT0PnjTdYzyttICzszu4OL5kj+X8GHZ8doL3tpXQM="; + }; + patches = [ + # this is necessary because the tests clear PATH/PYTHONPATH otherwise + ./test-pythonpath.patch + # minor difference in the test output, most likely due to different dependency versions + ./fix-test.patch + ]; + + nativeBuildInputs = with python3.pkgs; [ + setuptools-scm + pythonRelaxDepsHook + + pngquant + resvg + ]; + + # these two packages are just prebuilt wheels containing the respective binaries + pythonRemoveDeps = [ "pngquant-cli" "resvg-cli" ]; + + propagatedBuildInputs = with python3.pkgs; [ + absl-py + fonttools + lxml + ninja-python + picosvg + pillow + regex + toml + tomlkit + ufo2ft + ufoLib2 + zopfli + ]; + + nativeCheckInputs = with python3.pkgs; [ + pytestCheckHook + + ninja-python + picosvg + ]; + + makeWrapperArgs = [ + "--prefix PATH : ${lib.makeBinPath [ pngquant resvg ]}" + ]; + + preCheck = '' + # make sure the built binaries (nanoemoji/maximum_color) can be found by the test + export PATH="$out/bin:''${PATH}" + ''; + + meta = with lib; { + description = "A wee tool to build color fonts"; + homepage = "https://github.com/googlefonts/nanoemoji"; + license = licenses.asl20; + maintainers = with maintainers; [ _999eagle ]; + }; +} diff --git a/pkgs/tools/misc/nanoemoji/fix-test.patch b/pkgs/tools/misc/nanoemoji/fix-test.patch new file mode 100644 index 000000000000..4582df9ea5b8 --- /dev/null +++ b/pkgs/tools/misc/nanoemoji/fix-test.patch @@ -0,0 +1,24 @@ +--- a/tests/proportional_cbdt.ttx ++++ b/tests/proportional_cbdt.ttx +@@ -13,7 +13,7 @@ + + + +- ++ + + + +@@ -79,10 +79,10 @@ + + + +- ++ + + +- ++ + + + diff --git a/pkgs/tools/misc/nanoemoji/test-pythonpath.patch b/pkgs/tools/misc/nanoemoji/test-pythonpath.patch new file mode 100644 index 000000000000..12733224560c --- /dev/null +++ b/pkgs/tools/misc/nanoemoji/test-pythonpath.patch @@ -0,0 +1,14 @@ +--- a/tests/test_helper.py ++++ b/tests/test_helper.py +@@ -269,9 +269,9 @@ + print("subprocess:", " ".join(cmd)) # very useful on failure + env = { + # We may need to find nanoemoji and other pip-installed cli tools +- "PATH": str(Path(shutil.which("nanoemoji")).parent), ++ "PATH": str(Path(shutil.which("nanoemoji")).parent) + ":" + os.environ["PATH"], + # We may need to find test modules +- "PYTHONPATH": os.pathsep.join((str(Path(__file__).parent),)), ++ "PYTHONPATH": os.pathsep.join((str(Path(__file__).parent),)) + ":" + os.environ["PYTHONPATH"], + } + # Needed for windows CI to function; ref https://github.com/appveyor/ci/issues/1995 + if "SYSTEMROOT" in os.environ: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cc3904692e41..e52631f4bd61 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9727,6 +9727,8 @@ with pkgs; pythonPackages = python3Packages; }; + nanoemoji = python3Packages.callPackage ../tools/misc/nanoemoji { }; + nagelfar = callPackage ../development/tools/nagelfar { }; nats-top = callPackage ../tools/system/nats-top { }; From 0e1c1dad5fb4bcd5410e4a1ff19c09ded249655e Mon Sep 17 00:00:00 2001 From: Sandro Date: Fri, 21 Jul 2023 14:57:26 +0200 Subject: [PATCH 4/4] nanoemoji: avoid escaping hell --- pkgs/tools/misc/nanoemoji/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/misc/nanoemoji/default.nix b/pkgs/tools/misc/nanoemoji/default.nix index 0e584bc978aa..93817ff84798 100644 --- a/pkgs/tools/misc/nanoemoji/default.nix +++ b/pkgs/tools/misc/nanoemoji/default.nix @@ -60,7 +60,7 @@ python3.pkgs.buildPythonApplication rec { preCheck = '' # make sure the built binaries (nanoemoji/maximum_color) can be found by the test - export PATH="$out/bin:''${PATH}" + export PATH="$out/bin:$PATH" ''; meta = with lib; {