From 4c3715b9388da9ee507f52d3816e93600dcd60e4 Mon Sep 17 00:00:00 2001 From: Samuel Rounce Date: Tue, 21 May 2024 20:06:22 +0100 Subject: [PATCH] feat(loom): Add loom.ociImg attribute Loom docker images attribute exposed as passthru field of loom. Fixes #12 --- envs-flake/flake.lock | 6 +- flake.nix | 5 +- lib/mkScopes/default.nix | 12 +- pkgs/loom/default.nix | 244 ++++++++++++++++++++------------------- 4 files changed, 144 insertions(+), 123 deletions(-) diff --git a/envs-flake/flake.lock b/envs-flake/flake.lock index 195aba8..6dac351 100644 --- a/envs-flake/flake.lock +++ b/envs-flake/flake.lock @@ -312,12 +312,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-JkiJfITfqF/j9v19GZmKsSyHNg6QHcZm1zREtk9zyEE=", - "path": "/nix/store/g1pirymr2kh1fbp02pz12k5hzzx46r88-source", + "narHash": "sha256-7w80igMH0e1XmGeHgXUBJsV15sXGSeULGpkv9mt0LxI=", + "path": "/nix/store/mq6nsb219rr6kywfvchflxa43s9b17i3-source", "type": "path" }, "original": { - "path": "/nix/store/g1pirymr2kh1fbp02pz12k5hzzx46r88-source", + "path": "/nix/store/mq6nsb219rr6kywfvchflxa43s9b17i3-source", "type": "path" } }, diff --git a/flake.nix b/flake.nix index c8528f6..27b865f 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,10 @@ basicTools = self.lib.basicTools; }; - scopes = (self.lib.mkScopes pkgs); + scopes = (self.lib.mkScopes { + inherit pkgs; + basicTools = self.lib.basicTools; + }); loom = scopes.callPy3Package ./pkgs/loom { }; packages = loom.more_packages // { diff --git a/lib/mkScopes/default.nix b/lib/mkScopes/default.nix index be75515..3218d45 100644 --- a/lib/mkScopes/default.nix +++ b/lib/mkScopes/default.nix @@ -1,12 +1,18 @@ -pkgs: let +{ pkgs, basicTools }: let callPackage = pkgs.newScope ( pkgs - // { inherit callPackage; } + // { + inherit callPackage; + basicTools = basicTools pkgs; + } ); callPy3Package = pkgs.newScope ( pkgs // pkgs.python3Packages - // { inherit callPackage; } + // { + inherit callPackage; + basicTools = basicTools pkgs; + } ); in { inherit callPackage callPy3Package ; diff --git a/pkgs/loom/default.nix b/pkgs/loom/default.nix index 1f3df09..7a8292e 100644 --- a/pkgs/loom/default.nix +++ b/pkgs/loom/default.nix @@ -27,6 +27,8 @@ , zlib , eigen , gperftools +, dockerTools +, basicTools }: let goftests = callPackage ./../goftests { }; @@ -83,131 +85,141 @@ let # https://github.com/jazzband/contextlib2/pull/52 # updated to support Python3 src = fetchFromGitHub { - owner = "mr-c"; + owner = "jazzband"; repo = "contextlib2"; rev = "b8b7eb8ecd9e012178b5dcec4313edded751a459"; hash = "sha256-FSx/vKctoFl4NlwzNDa9eDNUXeW1J875/nB6of+5gQk="; }; }); -in -buildPythonPackage { - inherit version; - - src = loom-cpp.dev; - - pname = "loom"; - - nativeBuildInputs = [ - cmake - setuptools - wheel - protobuf - ]; - - buildInputs = [ - cmake - gnumake - - distributions.distributions-shared - distributions - zlib - eigen - gperftools - ]; - - nativeCheckInputs = [ - pyflakes - ]; - - # https://github.com/numba/numba/issues/8698#issuecomment-1584888063 - env.NUMPY_EXPERIMENTAL_DTYPE_API = 1; - - env.DISTRIBUTIONS_USE_PROTOBUF = 1; - - propagatedBuildInputs = [ - loom-cpp - contextlib2 - cpplint - cython_0 - distributions - distributions.distributions-shared - goftests - imageio - matplotlib - mock - nose - numpy - pandas - parsable - pep8 - python3Packages.protobuf - pyflakes - pymetis - scikit-learn - scipy - setuptools - simplejson - pytest - ]; - - # TODO: make tests run in checkPhase - doCheck = false; - - pythonImportsCheck = [ - "loom" - "loom.cleanse" - "loom.crossvalidate" - "loom.datasets" - "loom.format" - "loom.generate" - "loom.preql" - "loom.query" - "loom.schema_pb2" - "loom.store" - "loom.tasks" - "loom.transforms" - "loom.util" - "loom.watch" - ]; - - dontUseCmakeConfigure = true; - - enableParallelBuilding = true; - - prePatch = '' - sed -i 's/-Werror//g' CMakeLists.txt # remove -Werror - ''; - - passthru.loom-cpp = loom-cpp; - - passthru.more_packages = { - inherit + + loom = buildPythonPackage { + inherit version; + + src = loom-cpp.dev; + + pname = "loom"; + + nativeBuildInputs = [ + cmake + setuptools + wheel + protobuf + ]; + + buildInputs = [ + cmake + gnumake + + distributions.distributions-shared + distributions + zlib + eigen + gperftools + ]; + + nativeCheckInputs = [ + pyflakes + ]; + + # https://github.com/numba/numba/issues/8698#issuecomment-1584888063 + env.NUMPY_EXPERIMENTAL_DTYPE_API = 1; + + env.DISTRIBUTIONS_USE_PROTOBUF = 1; + + propagatedBuildInputs = [ + loom-cpp + contextlib2 + cpplint + cython_0 + distributions + distributions.distributions-shared + goftests + imageio + matplotlib + mock + nose + numpy + pandas + parsable + pep8 + python3Packages.protobuf + pyflakes + pymetis + scikit-learn + scipy + setuptools + simplejson + pytest + ]; + + # TODO: make tests run in checkPhase + doCheck = false; + + pythonImportsCheck = [ + "loom" + "loom.cleanse" + "loom.crossvalidate" + "loom.datasets" + "loom.format" + "loom.generate" + "loom.preql" + "loom.query" + "loom.schema_pb2" + "loom.store" + "loom.tasks" + "loom.transforms" + "loom.util" + "loom.watch" + ]; + + dontUseCmakeConfigure = true; + + enableParallelBuilding = true; + + prePatch = '' + sed -i 's/-Werror//g' CMakeLists.txt # remove -Werror + ''; + + passthru.loom-cpp = loom-cpp; + + passthru.more_packages = { + inherit goftests distributions pymetis parsable - ; - }; + ; + }; - passthru.tests.run = callPackage ./test.nix { inherit src; }; - - passthru.test-shell = callPackage ({ - mkShell - , python3 - , loom - , which - }: mkShell { - packages = [ - python3 - loom - which - ]; - }) {}; + passthru.ociImg = dockerTools.buildLayeredImage { + name = "probcomp/loom"; + contents = + with pkgs; [ loom bashInteractive ] ++ + basicTools + ; + }; - meta = with lib; { - description = "A streaming cross-cat inference engine"; - homepage = "https://github.com/emilyfertig/loom"; - license = licenses.bsd3; - maintainers = with maintainers; [ ]; + passthru.tests.run = callPackage ./test.nix { inherit src; }; + + passthru.test-shell = callPackage ({ + mkShell + , python3 + , loom + , which + }: mkShell { + packages = [ + python3 + loom + which + ]; + }) {}; + + meta = with lib; { + description = "A streaming cross-cat inference engine"; + homepage = "https://github.com/emilyfertig/loom"; + license = licenses.bsd3; + maintainers = with maintainers; [ ]; + }; }; -} +in +loom