Loading pkgs/development/python-modules/mlx/default.nix +16 −16 Original line number Diff line number Diff line Loading @@ -4,17 +4,16 @@ buildPythonPackage, fetchFromGitHub, replaceVars, nanobind, # build-system setuptools, # nativeBuildInputs cmake, setuptools, typing-extensions, # buildInputs apple-sdk, fmt, nanobind, nlohmann_json, pybind11, # linux-only Loading Loading @@ -42,26 +41,27 @@ let in buildPythonPackage (finalAttrs: { pname = "mlx"; version = "0.30.1"; version = "0.30.3"; pyproject = true; src = fetchFromGitHub { owner = "ml-explore"; repo = "mlx"; tag = "v${finalAttrs.version}"; hash = "sha256-Vt0RH+70VBwUjXSfPTsNdRS3g0ookJHhzf2kvgEtgH8="; hash = "sha256-Y4RTkGcDCZ9HLyflN0qYhPt/oVOsBhF1mHnKM4n1/ys="; }; patches = lib.optionals stdenv.hostPlatform.isDarwin [ patches = [ # Use system nanobind instead of fetching its sources ./dont-fetch-nanobind.patch ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ (replaceVars ./darwin-build-fixes.patch { sdkVersion = apple-sdk.version; }) ]; postPatch = '' substituteInPlace pyproject.toml \ --replace-fail "nanobind==2.10.2" "nanobind" substituteInPlace mlx/backend/cpu/jit_compiler.cpp \ --replace-fail "g++" "${lib.getExe' stdenv.cc "c++"}" ''; Loading @@ -79,7 +79,7 @@ buildPythonPackage (finalAttrs: { passthru.skipBulkUpdate = true; env = { DEV_RELEASE = 1; PYPI_RELEASE = 1; CMAKE_ARGS = toString [ # NOTE The `metal` command-line utility used to build the Metal kernels is not open-source. # To build mlx with Metal support in Nix, you'd need to use one of the sandbox escape Loading @@ -89,21 +89,21 @@ buildPythonPackage (finalAttrs: { (lib.cmakeBool "USE_SYSTEM_FMT" true) (lib.cmakeOptionType "filepath" "FETCHCONTENT_SOURCE_DIR_GGUFLIB" "${gguf-tools}") (lib.cmakeOptionType "filepath" "FETCHCONTENT_SOURCE_DIR_JSON" "${nlohmann_json.src}") # Cmake cannot find nanobind-config.cmake by itself (lib.cmakeFeature "nanobind_DIR" "${nanobind}/${python.sitePackages}/nanobind/cmake") ]; }; build-system = [ setuptools ]; nativeBuildInputs = [ cmake setuptools typing-extensions ]; buildInputs = [ fmt gguf-tools nanobind nlohmann_json pybind11 ] Loading pkgs/development/python-modules/mlx/dont-fetch-nanobind.patch 0 → 100644 +19 −0 Original line number Diff line number Diff line diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ed30932..e5842707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,13 +339,7 @@ if(MLX_BUILD_PYTHON_BINDINGS) Python 3.10 COMPONENTS Interpreter Development.Module REQUIRED) - FetchContent_Declare( - nanobind - GIT_REPOSITORY https://github.com/wjakob/nanobind.git - GIT_TAG v2.10.2 - GIT_SHALLOW TRUE - EXCLUDE_FROM_ALL) - FetchContent_MakeAvailable(nanobind) + find_package(nanobind CONFIG REQUIRED) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/python/src) endif() Loading
pkgs/development/python-modules/mlx/default.nix +16 −16 Original line number Diff line number Diff line Loading @@ -4,17 +4,16 @@ buildPythonPackage, fetchFromGitHub, replaceVars, nanobind, # build-system setuptools, # nativeBuildInputs cmake, setuptools, typing-extensions, # buildInputs apple-sdk, fmt, nanobind, nlohmann_json, pybind11, # linux-only Loading Loading @@ -42,26 +41,27 @@ let in buildPythonPackage (finalAttrs: { pname = "mlx"; version = "0.30.1"; version = "0.30.3"; pyproject = true; src = fetchFromGitHub { owner = "ml-explore"; repo = "mlx"; tag = "v${finalAttrs.version}"; hash = "sha256-Vt0RH+70VBwUjXSfPTsNdRS3g0ookJHhzf2kvgEtgH8="; hash = "sha256-Y4RTkGcDCZ9HLyflN0qYhPt/oVOsBhF1mHnKM4n1/ys="; }; patches = lib.optionals stdenv.hostPlatform.isDarwin [ patches = [ # Use system nanobind instead of fetching its sources ./dont-fetch-nanobind.patch ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ (replaceVars ./darwin-build-fixes.patch { sdkVersion = apple-sdk.version; }) ]; postPatch = '' substituteInPlace pyproject.toml \ --replace-fail "nanobind==2.10.2" "nanobind" substituteInPlace mlx/backend/cpu/jit_compiler.cpp \ --replace-fail "g++" "${lib.getExe' stdenv.cc "c++"}" ''; Loading @@ -79,7 +79,7 @@ buildPythonPackage (finalAttrs: { passthru.skipBulkUpdate = true; env = { DEV_RELEASE = 1; PYPI_RELEASE = 1; CMAKE_ARGS = toString [ # NOTE The `metal` command-line utility used to build the Metal kernels is not open-source. # To build mlx with Metal support in Nix, you'd need to use one of the sandbox escape Loading @@ -89,21 +89,21 @@ buildPythonPackage (finalAttrs: { (lib.cmakeBool "USE_SYSTEM_FMT" true) (lib.cmakeOptionType "filepath" "FETCHCONTENT_SOURCE_DIR_GGUFLIB" "${gguf-tools}") (lib.cmakeOptionType "filepath" "FETCHCONTENT_SOURCE_DIR_JSON" "${nlohmann_json.src}") # Cmake cannot find nanobind-config.cmake by itself (lib.cmakeFeature "nanobind_DIR" "${nanobind}/${python.sitePackages}/nanobind/cmake") ]; }; build-system = [ setuptools ]; nativeBuildInputs = [ cmake setuptools typing-extensions ]; buildInputs = [ fmt gguf-tools nanobind nlohmann_json pybind11 ] Loading
pkgs/development/python-modules/mlx/dont-fetch-nanobind.patch 0 → 100644 +19 −0 Original line number Diff line number Diff line diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ed30932..e5842707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,13 +339,7 @@ if(MLX_BUILD_PYTHON_BINDINGS) Python 3.10 COMPONENTS Interpreter Development.Module REQUIRED) - FetchContent_Declare( - nanobind - GIT_REPOSITORY https://github.com/wjakob/nanobind.git - GIT_TAG v2.10.2 - GIT_SHALLOW TRUE - EXCLUDE_FROM_ALL) - FetchContent_MakeAvailable(nanobind) + find_package(nanobind CONFIG REQUIRED) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/python/src) endif()