From 62e106f88779406eb460023008dc309e7e7e1b22 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 21 Apr 2026 11:55:32 +0000 Subject: [PATCH] python3Packages.nixl: init at 1.0.1 --- pkgs/by-name/ni/nixl/package.nix | 5 ++ .../python-modules/nixl/default.nix | 84 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 91 insertions(+) create mode 100644 pkgs/development/python-modules/nixl/default.nix diff --git a/pkgs/by-name/ni/nixl/package.nix b/pkgs/by-name/ni/nixl/package.nix index 9232b9281d07..a0101488ffc3 100644 --- a/pkgs/by-name/ni/nixl/package.nix +++ b/pkgs/by-name/ni/nixl/package.nix @@ -137,6 +137,11 @@ effectiveStdenv.mkDerivation (finalAttrs: { passthru = { updateScript = nix-update-script { }; + + # propagate the stdenv so that the python API can consume it directly + stdenv = effectiveStdenv; + + pythonPackage = python3Packages.nixl; }; meta = { diff --git a/pkgs/development/python-modules/nixl/default.nix b/pkgs/development/python-modules/nixl/default.nix new file mode 100644 index 000000000000..8aa00155a58d --- /dev/null +++ b/pkgs/development/python-modules/nixl/default.nix @@ -0,0 +1,84 @@ +{ + lib, + buildPythonPackage, + python, + nixl, + + # build-system + build, + meson-python, + pybind11, + pytest, + pyyaml, + setuptools, + types-pyyaml, + + # dependencies + numpy, + torch, + + config, + cudaSupport ? config.cudaSupport, + cudaPackages, +}: + +buildPythonPackage.override { inherit (nixl) stdenv; } (finalAttrs: { + inherit (nixl) + pname + version + src + __structuredAttrs + strictDeps + nativeBuildInputs + dontUseCmakeConfigure + buildInputs + mesonFlags + ; + pyproject = true; + + postPatch = (nixl.postPatch or "") + '' + substituteInPlace pyproject.toml \ + --replace-fail \ + '"patchelf",' \ + "" + ''; + + build-system = [ + build + meson-python + pybind11 + pytest + pyyaml + setuptools + types-pyyaml + ]; + dontUseMesonConfigure = true; + + dependencies = [ + numpy + torch + ]; + + # Install the `nixl` shim module (re-exports nixl_cu{12,13}). + # Upstream builds this as a separate wheel via `uv build` (nixl-meta), but that doesn't work in + # the sandbox. + postInstall = '' + install -Dm644 \ + src/bindings/python/nixl-meta/nixl/__init__.py \ + "$out/${python.sitePackages}/nixl/__init__.py" + ''; + + pythonImportsCheck = [ + "nixl" + ] + ++ lib.optionals cudaSupport [ + "nixl_cu${cudaPackages.cudaMajorVersion}" + ]; + + # No tests we can run in the sandbox + doCheck = false; + + meta = nixl.meta // { + description = "Python API for nixl"; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c14b91280b61..d339b67b1b87 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -11132,6 +11132,8 @@ self: super: with self; { nix-prefetch-github = callPackage ../development/python-modules/nix-prefetch-github { }; + nixl = callPackage ../development/python-modules/nixl { inherit (pkgs) nixl; }; + nixpkgs-plugin-update = callPackage ../development/python-modules/nixpkgs-plugin-update { }; nixpkgs-pytools = callPackage ../development/python-modules/nixpkgs-pytools { };