From c5caf61d0950a158563f143a9c4447437c2183db Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 22 Jan 2026 09:32:20 +0000 Subject: [PATCH 1/2] python3Packages.pyclibrary: init at 0.3.0 --- .../python-modules/pyclibrary/default.nix | 49 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 51 insertions(+) create mode 100644 pkgs/development/python-modules/pyclibrary/default.nix diff --git a/pkgs/development/python-modules/pyclibrary/default.nix b/pkgs/development/python-modules/pyclibrary/default.nix new file mode 100644 index 000000000000..442854a9055d --- /dev/null +++ b/pkgs/development/python-modules/pyclibrary/default.nix @@ -0,0 +1,49 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + setuptools, + setuptools-scm, + pyparsing, + + # tests + pytestCheckHook, +}: + +buildPythonPackage (finalAttrs: { + pname = "pyclibrary"; + version = "0.3.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "MatthieuDartiailh"; + repo = "pyclibrary"; + tag = finalAttrs.version; + hash = "sha256-RyIbRySRWSZwKP5G6yXYCOnfKOV0165aPyjMf3nSbOM="; + }; + + build-system = [ + setuptools + setuptools-scm + ]; + + dependencies = [ + pyparsing + ]; + + pythonImportsCheck = [ "pyclibrary" ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + meta = { + description = "C parser and ctypes automation for python"; + homepage = "https://github.com/MatthieuDartiailh/pyclibrary"; + changelog = "https://github.com/MatthieuDartiailh/pyclibrary/blob/${finalAttrs.src.tag}/CHANGES"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c0f172b404a1..8c28f86bb197 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -13147,6 +13147,8 @@ self: super: with self; { pycketcasts = callPackage ../development/python-modules/pycketcasts { }; + pyclibrary = callPackage ../development/python-modules/pyclibrary { }; + pyclimacell = callPackage ../development/python-modules/pyclimacell { }; pyclip = callPackage ../development/python-modules/pyclip { }; From 5764652645158001733fbc9457a3804922240a05 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Thu, 22 Jan 2026 09:32:33 +0000 Subject: [PATCH 2/2] python3Packages.cuda-bindings: init at 12.8.0 --- .../python-modules/cuda-bindings/default.nix | 142 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 144 insertions(+) create mode 100644 pkgs/development/python-modules/cuda-bindings/default.nix diff --git a/pkgs/development/python-modules/cuda-bindings/default.nix b/pkgs/development/python-modules/cuda-bindings/default.nix new file mode 100644 index 000000000000..288e4a2ffdc9 --- /dev/null +++ b/pkgs/development/python-modules/cuda-bindings/default.nix @@ -0,0 +1,142 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + cudaPackages, + addDriverRunpath, + + # build-system + cython, + setuptools, + pyclibrary, + + # env + symlinkJoin, + + # tests + numpy, + pytestCheckHook, + + # passthru + cuda-bindings, +}: + +buildPythonPackage (finalAttrs: { + pname = "cuda-bindings"; + version = "12.8.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = "cuda-python"; + tag = "v${finalAttrs.version}"; + hash = "sha256-7e9w70KkC6Pcvyu6Cwt5Asrc3W9TgsjiGvArRTer6Oc="; + }; + + sourceRoot = "${finalAttrs.src.name}/cuda_bindings"; + + postPatch = + let + libCudaPath = + # Use cuda_compat to provide libcuda.so on pre-Thor Jetsons + if (cudaPackages.cuda_compat.meta.available or false) then + cudaPackages.cuda_compat + + # Else, use the host CUDA driver library + else + addDriverRunpath.driverLink; + in + '' + substituteInPlace cuda/bindings/_internal/nvjitlink_linux.pyx \ + --replace-fail \ + 'so_name = "libnvJitLink.so"' \ + 'so_name = "${lib.getLib cudaPackages.libnvjitlink}/lib/libnvJitLink.so"' \ + --replace-fail \ + "handle = dlopen('libcuda.so.1'" \ + "handle = dlopen('${libCudaPath}/lib/libcuda.so.1'" + + substituteInPlace cuda/bindings/_bindings/cydriver.pyx.in \ + --replace-fail \ + "path = 'libcuda.so.1'" \ + "path = '${libCudaPath}/lib/libcuda.so.1'" + + substituteInPlace cuda/bindings/_bindings/cynvrtc.pyx.in \ + --replace-fail \ + "dlfcn.dlopen('libnvrtc.so.12'" \ + "dlfcn.dlopen('${lib.getLib cudaPackages.cuda_nvrtc}/lib/libnvrtc.so.12'" + + substituteInPlace cuda/bindings/_lib/cyruntime/cyruntime.pyx.in \ + --replace-fail \ + "dlfcn.dlopen('libcudart.so.12'" \ + "dlfcn.dlopen('${lib.getLib cudaPackages.cuda_cudart}/lib/libcudart.so.12'" + ''; + + preBuild = '' + export CUDA_PYTHON_PARALLEL_LEVEL=$NIX_BUILD_CORES + ''; + + build-system = [ + cython + pyclibrary + setuptools + ]; + + env = { + CUDA_HOME = symlinkJoin { + name = "cuda-redist"; + paths = with cudaPackages; [ + (lib.getInclude cuda_cudart) # cuda_runtime.h + (lib.getInclude cuda_nvrtc) # nvrtc.h + (lib.getInclude cuda_profiler_api) # cudaProfiler.h, cuda_profiler_api.h + ]; + }; + }; + + buildInputs = [ + cudaPackages.cuda_nvcc # crt/host_defines.h + ]; + + pythonImportsCheck = [ + "cuda" + "cuda.cuda" + "cuda.cudart" + "cuda.nvrtc" + ]; + + preCheck = '' + rm -rf cuda + ''; + + nativeCheckInputs = [ + numpy + pytestCheckHook + ]; + + enabledTestPaths = [ + "tests/" + ]; + + disabledTestPaths = [ + # The current driver shipped in NixOS (590.48.01) advertises CUDA 13.1, causing the following + # error: + # cuda.bindings._internal.utils.NotSupportedError: only CUDA 12 driver is supported + # + # Ideally, we should transition to cuda 13 across the whole nixpkgs tree. + "tests/test_nvjitlink.py" + ]; + + # Tests need access to a GPU + doCheck = false; + passthru.gpuCheck = cuda-bindings.overridePythonAttrs { + requiredSystemFeatures = [ "cuda" ]; + doCheck = true; + }; + + meta = { + description = "CUDA Python: Performance meets Productivity"; + homepage = "https://github.com/NVIDIA/cuda-python/tree/main/cuda_bindings"; + changelog = "https://nvidia.github.io/cuda-python/${finalAttrs.version}/release/${finalAttrs.version}-notes.html"; + license = lib.licenses.unfreeRedistributable; # NVIDIA Proprietary Software + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8c28f86bb197..49ff6d89277e 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3338,6 +3338,8 @@ self: super: with self; { cucumber-tag-expressions = callPackage ../development/python-modules/cucumber-tag-expressions { }; + cuda-bindings = callPackage ../development/python-modules/cuda-bindings { }; + cupy = callPackage ../development/python-modules/cupy { cudaPackages = # CuDNN 9 is not supported: