From d98506296b665e543fe1ff4b99acc96b839719ac Mon Sep 17 00:00:00 2001 From: Ankur Kumar Date: Sun, 5 Jan 2025 09:04:16 -0500 Subject: [PATCH] feat(nix): setup to move towards uv workspace --- nix/containers/default.nix | 11 ---------- nix/containers/illum-calculate.nix | 20 ++++++++--------- nix/cpgdata.nix | 16 ++++++++------ nix/cpgparser.nix | 35 +++++++++++------------------- nix/default.nix | 17 +++++++++++---- nix/pipecraft.nix | 11 ++-------- nix/starrynight.nix | 7 ++++-- 7 files changed, 52 insertions(+), 65 deletions(-) delete mode 100644 nix/containers/default.nix diff --git a/nix/containers/default.nix b/nix/containers/default.nix deleted file mode 100644 index bea874e..0000000 --- a/nix/containers/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - pkgs, - inputs, - outputs, - ... -}: -{ - imports = [ - (import pkgs.callPackage ./illum-calculate.nix { }) - ]; -} diff --git a/nix/containers/illum-calculate.nix b/nix/containers/illum-calculate.nix index 90cf476..5df41fe 100644 --- a/nix/containers/illum-calculate.nix +++ b/nix/containers/illum-calculate.nix @@ -1,16 +1,16 @@ { - inputs, + pkgs, + nix2container, outputs, ... }: -{ - illum_calculate = inputs.nix2container.buildImage { - name = "starrynight-illum-calculate"; - config = { - entrypoint = [ - "${outputs.packages.starrynight}/bin/starrynight" - "illum" - ]; - }; +pkgs.dockerTools.buildImage { + name = "ghcr.io/broadinstitute/starrynight-illum-calculate"; + tag = "dev"; + config = { + Cmd = [ + "${outputs.packages.${pkgs.system}.starrynight}/bin/starrynight" + "illum" + ]; }; } diff --git a/nix/cpgdata.nix b/nix/cpgdata.nix index 69c3f70..b46dcf6 100644 --- a/nix/cpgdata.nix +++ b/nix/cpgdata.nix @@ -2,6 +2,7 @@ lib, buildPythonPackage, fetchPypi, + poetry-core, pytest, cython, setuptools, @@ -15,28 +16,29 @@ tqdm, lark, }: -buildPythonPackage { +buildPythonPackage rec { pname = "cpgdata"; version = "0.4.0"; src = fetchPypi { inherit pname version; - sha256 = ""; + sha256 = "sha256-nCDzjnEXD0Hs4lfS9NP9DbG0ly84Y8NDICbvpuMD1cU="; }; pyproject = true; # Relax deps constraints - # postPatch = '' - # substituteInPlace setup.py \ - # --replace "scipy>=1.4.1,<1.11" "scipy>=1.4.1" \ - # --replace "matplotlib>=3.1.3,<3.8" "matplotlib>=3.1.3" - # ''; + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-warn 'polars = "^0.19"' 'polars = ">=0.19"' \ + --replace-warn 'pyarrow = "^13.0"' 'pyarrow = ">=13.0"' + ''; buildInputs = [ pytest cython setuptools setuptools-scm + poetry-core ]; propagatedBuildInputs = [ diff --git a/nix/cpgparser.nix b/nix/cpgparser.nix index 91cd29a..6e68d7e 100644 --- a/nix/cpgparser.nix +++ b/nix/cpgparser.nix @@ -2,39 +2,30 @@ lib, buildPythonPackage, fetchPypi, - pytest, - cython, - setuptools, - setuptools-scm, - maturin, + rustPlatform, }: -buildPythonPackage { +buildPythonPackage rec { pname = "cpgparser"; version = "0.2.0"; + pyproject = true; src = fetchPypi { inherit pname version; - sha256 = ""; + sha256 = "sha256-5k3u873kKKFyP2qps1Buq+SmIuU0BPUfa23+FaAoomE="; }; - pyproject = true; - - # Relax deps constraints - # postPatch = '' - # substituteInPlace setup.py \ - # --replace "scipy>=1.4.1,<1.11" "scipy>=1.4.1" \ - # --replace "matplotlib>=3.1.3,<3.8" "matplotlib>=3.1.3" - # ''; - buildInputs = [ - pytest - cython - setuptools - setuptools-scm - maturin + nativeBuildInputs = with rustPlatform; [ + maturinBuildHook + cargoSetupHook ]; - propagatedBuildInputs = [ + cargoDeps = rustPlatform.fetchCargoTarball { + inherit pname version src; + hash = "sha256-uz/q3cnWNf9k8bNeUIh1gzJGCWWOnPSwSoAgvlwAdlo="; + }; + + dependencies = [ ]; pythonImportsCheck = [ "cpgparser" ]; diff --git a/nix/default.nix b/nix/default.nix index 28c3fad..aa93ba0 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -8,15 +8,24 @@ }: let + # tools + inherit (inputs.nix2container.packages.${pkgs.system}) nix2container; # Apps packages = rec { + cp-pkgs = inputs.cp-flake.packages.${pkgs.system}; pipecraft = python3Packages.callPackage ./pipecraft.nix { }; cpgparser = python3Packages.callPackage ./cpgparser.nix { }; - # cpgdata = python3Packages.callPackage ./cpgdata.nix { }; - # starrynight = python3Packages.callPackage ./starrynight.nix { inherit pipecraft cpgdata; }; + cpgdata = python3Packages.callPackage ./cpgdata.nix { inherit cpgparser; }; + starrynight = python3Packages.callPackage ./starrynight.nix { + inherit cpgdata pipecraft; + inherit (cp-pkgs) cellprofiler cellprofiler-core cellprofiler-library; + }; + + # Containers + container_illum_calculate = pkgs.callPackage ./containers/illum-calculate.nix { + inherit nix2container outputs; + }; }; in -# Containers -# containers = import pkgs.callPackage ./containers { }; packages diff --git a/nix/pipecraft.nix b/nix/pipecraft.nix index 27e76e7..cbc9611 100644 --- a/nix/pipecraft.nix +++ b/nix/pipecraft.nix @@ -18,13 +18,6 @@ buildPythonPackage { src = ./../pipecraft; pyproject = true; - # Relax deps constraints - # postPatch = '' - # substituteInPlace setup.py \ - # --replace "scipy>=1.4.1,<1.11" "scipy>=1.4.1" \ - # --replace "matplotlib>=3.1.3,<3.8" "matplotlib>=3.1.3" - # ''; - buildInputs = [ pytest cython @@ -42,8 +35,8 @@ buildPythonPackage { pythonImportsCheck = [ "pipecraft" ]; meta = { - description = "Centrosome"; - homepage = "https://cellprofiler.org"; + description = "Pipecraft library for crafting data pipelines in python"; + homepage = "https://github.com/broadinstitute/starrynight"; license = lib.licenses.mit; }; diff --git a/nix/starrynight.nix b/nix/starrynight.nix index d63d46b..3e70091 100644 --- a/nix/starrynight.nix +++ b/nix/starrynight.nix @@ -6,6 +6,7 @@ setuptools, setuptools-scm, pipecraft, + cpgdata, lark, numpy, contourpy, @@ -18,6 +19,7 @@ buildPythonPackage { pname = "starrynight"; version = "0.1.0"; + pyproject = true; src = ./../starrynight; @@ -37,6 +39,7 @@ buildPythonPackage { propagatedBuildInputs = [ pipecraft + cpgdata lark numpy contourpy @@ -49,8 +52,8 @@ buildPythonPackage { pythonImportsCheck = [ "starrynight" ]; meta = { - description = "Centrosome"; - homepage = "https://cellprofiler.org"; + description = "Starrynight"; + homepage = "https://github.com/broadinstitute/bin/starrynight"; license = lib.licenses.mit; };