python3Packages.mlx: remove gguf-tools and pybind11 from buildInputs; enable for x86_64-darwin; use nlohmann_json from nixpkgs (#483750)
This commit is contained in:
@@ -56,13 +56,10 @@ python3Packages.buildPythonApplication rec {
|
||||
llama-cpp-vulkan
|
||||
podman
|
||||
]
|
||||
++ (
|
||||
with python3Packages;
|
||||
[
|
||||
huggingface-hub
|
||||
]
|
||||
++ lib.optional (lib.meta.availableOn stdenv.hostPlatform mlx-lm) mlx-lm
|
||||
)
|
||||
++ (with python3Packages; [
|
||||
huggingface-hub
|
||||
mlx-lm
|
||||
])
|
||||
)
|
||||
}
|
||||
'';
|
||||
|
||||
@@ -84,9 +84,5 @@ buildPythonPackage (finalAttrs: {
|
||||
homepage = "https://github.com/ml-explore/mlx-lm";
|
||||
changelog = "https://github.com/ml-explore/mlx-lm/releases/tag/${finalAttrs.src.tag}";
|
||||
license = lib.licenses.mit;
|
||||
badPlatforms = [
|
||||
# Building for x86_64 on macOS is not supported by mlx (dependency)
|
||||
"x86_64-darwin"
|
||||
];
|
||||
};
|
||||
})
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
apple-sdk,
|
||||
fmt,
|
||||
nlohmann_json,
|
||||
pybind11,
|
||||
# linux-only
|
||||
openblas,
|
||||
|
||||
@@ -52,8 +51,9 @@ buildPythonPackage (finalAttrs: {
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Use system nanobind instead of fetching its sources
|
||||
# Use nix packages instead of fetching their sources
|
||||
./dont-fetch-nanobind.patch
|
||||
./dont-fetch-json.patch
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
(replaceVars ./darwin-build-fixes.patch {
|
||||
@@ -80,19 +80,24 @@ buildPythonPackage (finalAttrs: {
|
||||
|
||||
env = {
|
||||
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
|
||||
# hatches which let you interact with a native install of Xcode, such as `composeXcodeWrapper`
|
||||
# or by changing the upstream (e.g., https://github.com/zed-industries/zed/discussions/7016).
|
||||
(lib.cmakeBool "MLX_BUILD_METAL" false)
|
||||
(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_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
|
||||
# hatches which let you interact with a native install of Xcode, such as `composeXcodeWrapper`
|
||||
# or by changing the upstream (e.g., https://github.com/zed-industries/zed/discussions/7016).
|
||||
(lib.cmakeBool "MLX_BUILD_METAL" false)
|
||||
(lib.cmakeBool "USE_SYSTEM_FMT" true)
|
||||
(lib.cmakeOptionType "filepath" "FETCHCONTENT_SOURCE_DIR_GGUFLIB" "${gguf-tools}")
|
||||
(lib.cmakeFeature "CMAKE_CXX_FLAGS" "-I${lib.getDev nlohmann_json}/include/nlohmann")
|
||||
|
||||
# Cmake cannot find nanobind-config.cmake by itself
|
||||
(lib.cmakeFeature "nanobind_DIR" "${nanobind}/${python.sitePackages}/nanobind/cmake")
|
||||
];
|
||||
# Cmake cannot find nanobind-config.cmake by itself
|
||||
(lib.cmakeFeature "nanobind_DIR" "${nanobind}/${python.sitePackages}/nanobind/cmake")
|
||||
]
|
||||
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
|
||||
(lib.cmakeBool "MLX_ENABLE_X64_MAC" true)
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
build-system = [
|
||||
@@ -103,9 +108,7 @@ buildPythonPackage (finalAttrs: {
|
||||
|
||||
buildInputs = [
|
||||
fmt
|
||||
gguf-tools
|
||||
nlohmann_json
|
||||
pybind11
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
openblas
|
||||
@@ -180,9 +183,5 @@ buildPythonPackage (finalAttrs: {
|
||||
cameronyule
|
||||
viraptor
|
||||
];
|
||||
badPlatforms = [
|
||||
# Building for x86_64 on macOS is not supported
|
||||
"x86_64-darwin"
|
||||
];
|
||||
};
|
||||
})
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 2451aa65..f88d4889 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -241,14 +241,6 @@ else()
|
||||
set(MLX_BUILD_ACCELERATE OFF)
|
||||
endif()
|
||||
|
||||
-message(STATUS "Downloading json")
|
||||
-FetchContent_Declare(
|
||||
- json
|
||||
- URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
|
||||
-FetchContent_MakeAvailable(json)
|
||||
-target_include_directories(
|
||||
- mlx PRIVATE $<BUILD_INTERFACE:${json_SOURCE_DIR}/single_include/nlohmann>)
|
||||
-
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/mlx)
|
||||
|
||||
target_include_directories(
|
||||
|
||||
Reference in New Issue
Block a user